feat(esm): yarn cedarjs test for both CJS and ESM projects#365
Conversation
✅ Deploy Preview for cedarjs canceled.
|
There was a problem hiding this comment.
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.jsand test file implementations
4 files reviewed, 4 comments
PR 13/n for adding experimental ESM support to Cedar apps. 1/n in this series was #349