Skip to content

feat(esm): yarn cedarjs test for both CJS and ESM projects#365

Merged
Tobbe merged 4 commits into
mainfrom
tobbe-esm-test-command
Aug 10, 2025
Merged

feat(esm): yarn cedarjs test for both CJS and ESM projects#365
Tobbe merged 4 commits into
mainfrom
tobbe-esm-test-command

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented Aug 10, 2025

PR 13/n for adding experimental ESM support to Cedar apps. 1/n in this series was #349

@Tobbe Tobbe added this to the next-release milestone Aug 10, 2025
@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 10, 2025

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit ff45563
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/689859af0a6c49000892c078

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR implements ESM (ECMAScript Module) support for the yarn cedarjs test command by creating parallel ESM-specific test infrastructure alongside the existing CommonJS implementation. The changes introduce a dual-path approach where the CLI dynamically selects between Jest (for CJS projects) and Vitest (for ESM projects) based on project type detection.

The core implementation adds four new files: testHanderEsm.js (ESM test handler using Vitest), testEsm.js (ESM command definition), and corresponding test coverage. The existing CLI index is modified to conditionally load the appropriate test command using projectIsEsm() detection. This maintains backward compatibility for existing CJS projects while enabling modern ESM support.

The ESM handler mirrors the functionality of the existing Jest-based handler but adapts to Vitest's different flag structure and execution model. Key behavioral changes include simplified watch mode logic (no Jest source control detection), different flag filtering, and removal of Jest-specific configuration file validation. The handler maintains feature parity including database setup, side filtering (web/api), and telemetry integration.

Confidence score: 3/5

  • This PR introduces significant complexity with runtime module system detection that could fail silently or cause confusion
  • Score reflects concerns about dynamic command loading, potential test coverage gaps, and the global variable assignment in test files
  • Pay close attention to the conditional loading logic in packages/cli/src/index.js and test file implementations

4 files reviewed, 4 comments

Edit Code Review Bot Settings | Greptile

Comment thread packages/cli/src/commands/testHanderEsm.js Outdated
Comment thread packages/cli/src/commands/__tests__/test.testEsm.js Outdated
Comment thread packages/cli/src/commands/__tests__/test.testEsm.js Outdated
Comment thread packages/cli/src/commands/__tests__/test.testEsm.js
@Tobbe Tobbe merged commit fe4a71b into main Aug 10, 2025
50 checks passed
@Tobbe Tobbe deleted the tobbe-esm-test-command branch August 10, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant