Skip to content

feat(esm): Create ESM Cedar App using hidden --esm flag#367

Merged
Tobbe merged 1 commit into
mainfrom
tobbe-esm-create-cedar-app-esm-hidden
Aug 10, 2025
Merged

feat(esm): Create ESM Cedar App using hidden --esm flag#367
Tobbe merged 1 commit into
mainfrom
tobbe-esm-create-cedar-app-esm-hidden

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented Aug 10, 2025

With this PR I add support for a hidden --esm flag you can pass to yarn create cedar-app to generate an app based on our ESM template

Until #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

@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 11901f8
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6898720600584f00080836d2

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 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

Edit Code Review Bot Settings | Greptile

Comment thread packages/create-cedar-app/src/create-cedar-app.js
@Tobbe Tobbe enabled auto-merge (squash) August 10, 2025 10:24
@Tobbe Tobbe merged commit 1dcfc0b into main Aug 10, 2025
51 of 52 checks passed
@Tobbe Tobbe deleted the tobbe-esm-create-cedar-app-esm-hidden branch August 10, 2025 10:30
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