Skip to content

Conversation

@Apollon77
Copy link
Collaborator

Implements feature request from issue #1127 to support ECMAScript Modules (ESM) in generated adapters, providing better compatibility with modern dependencies.

Changes:

  • Add moduleType question in Code section with ESM as default (expert option)
  • Update Answers interface with moduleType property (esm | commonjs)
  • Modify package.json template to include "type": "module" for ESM
  • Update TypeScript main template with ESM imports and export patterns
  • Update JavaScript main template with ESM imports and export patterns
  • Configure tsconfig.json with ESM-specific compiler options (module: ES2022, moduleResolution: bundler)
  • Add comment in io-package.json noting ESM compatibility with compact mode (requires js-controller >= 6.0.11)

Benefits:

  • Prevents issues with ESM-only dependencies
  • Enables modern JavaScript features
  • Works with js-controller 6.0.11+ compact mode
  • Backward compatible via CommonJS option

Fixes #1127

PR Checklist:

  • Provide a meaningful description to this PR or mention which issues this fixes.
  • Ensure the project builds with npm run build
  • Add tests for your change. This includes negative tests (i.e. inputs that need to fail) as well as baseline tests (i.e. how should the directory structure look like?).
  • Run the test suite with npm test
  • If there are baseline changes, review them and make a separate commit for them with the comment "accept baselines" if they are desired changes
  • If you added a required option, also add it to the template creation (.github/create_templates.ts)
  • Add a detailed migration description to docs/updates explaining what the user needs to do when manually updating an existing project
  • Add your changes to CHANGELOG.md (referencing the migration description and this PR or the issue you fixed)

Description:
add description here

Implements feature request from issue #1127 to support ECMAScript Modules (ESM)
in generated adapters, providing better compatibility with modern dependencies.

Changes:
- Add moduleType question in Code section with ESM as default (expert option)
- Update Answers interface with moduleType property (esm | commonjs)
- Modify package.json template to include "type": "module" for ESM
- Update TypeScript main template with ESM imports and export patterns
- Update JavaScript main template with ESM imports and export patterns
- Configure tsconfig.json with ESM-specific compiler options (module: ES2022, moduleResolution: bundler)
- Add comment in io-package.json noting ESM compatibility with compact mode (requires js-controller >= 6.0.11)

Benefits:
- Prevents issues with ESM-only dependencies
- Enables modern JavaScript features
- Works with js-controller 6.0.11+ compact mode
- Backward compatible via CommonJS option

Fixes #1127
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.

Add ESM module option

3 participants