feat(esm): Create ESM Cedar App using hidden --esm flag#367
Conversation
✅ Deploy Preview for cedarjs canceled.
|
There was a problem hiding this comment.
Greptile Summary
This PR introduces experimental ESM (ECMAScript Modules) support to the Cedar app creation process. The implementation adds a hidden --esm command-line flag that allows developers to create Cedar applications using ES modules instead of the default CommonJS format.
The core changes include:
ESM Flag Processing: A new handleEsmPreference function processes the --esm flag and defaults to CommonJS when no flag is provided. This follows the same pattern as the existing TypeScript preference handling, maintaining consistency with the codebase architecture.
Template Selection Logic: The template directory selection now supports four combinations: js/ts with cjs/esm. The logic uses nested ternary operators to choose between esm-ts, esm-js, ts, and js templates based on both TypeScript and ESM preferences.
Hidden Feature Flag: The ESM option is currently hidden from end users (hidden: true in CLI configuration), indicating this is an experimental feature being prepared for future release. An interactive prompt for ESM selection is commented out, suggesting plans for eventual user-facing prompts.
Telemetry Integration: ESM preference tracking is integrated into the existing telemetry system to monitor usage patterns during the experimental phase.
The changes also include minor documentation improvements to the e2e test setup, providing clear instructions for local test execution with the required PROJECT_PATH environment variable.
This implementation prepares the foundation for ESM support while allowing internal testing and validation without exposing the feature to end users yet. The structured approach ensures compatibility with existing templates while accommodating the new ESM variants.
Confidence score: 4/5
- This PR introduces experimental functionality with appropriate safeguards and follows established patterns in the codebase
- Score reflects the experimental nature and hidden flag approach, which limits immediate user impact while allowing testing
- Pay close attention to template directory structure and ensure ESM templates (
esm-ts,esm-js) exist in the expected locations
2 files reviewed, 1 comment
With this PR I add support for a hidden
--esmflag you can pass toyarn create cedar-appto generate an app based on our ESM templateUntil #80 is merged, the ESM app will not have full functionality. So for now, generation works, but you can't run it
PR 15/n in the #349 series