Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for node ESM addons #10053

Merged
merged 2 commits into from Oct 19, 2022
Merged

Add support for node ESM addons #10053

merged 2 commits into from Oct 19, 2022

Conversation

hjdivad
Copy link
Contributor

@hjdivad hjdivad commented Oct 17, 2022

Node has support for packages that export files in ES module syntax. See module packages in the node documentation.

This feature doesn't quite work with ember addons due to in-addon files being loaded:

  1. absolutely and
  2. via require

Relative requires can be made to work with conditional exports, but even that would require addon authors to write those files in commonjs format.

Absolute requires cannot be made to work unless the file loaded has a cjs suffix.

This PR makes it possible to write ember addons that opt in to ES module syntax. The support is imperfect since config/environment.js still has to be in commonjs format, so in practice addon authors need to write:

// config/package.json
{
  "type": "commonjs"
}

Co-authored-by: Robert Jackson <rjackson@linkedin.com>
@hjdivad
Copy link
Contributor Author

hjdivad commented Oct 18, 2022

@rwjblue obviously don't merge while there's a fixup! commit

I left it that way to make it easier to see the additional diff re the slow tests + watcher support

Also await the actual build function, so ember-cli-build.js can export
an async builder function.

Co-authored-by: Robert Jackson <rjackson@linkedin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants