embroider-build / ember-auto-import

Zero config import from npm packages
Other
360 stars 109 forks source link

Add support for consumers using Node ES Module support (e.g. `type=module` in `package.json`) #544

Closed hjdivad closed 1 year ago

hjdivad commented 1 year ago

Adds support for Ember addons that opt-in to node's ES module syntax via type=module.

When writing to a directory whose package.json is controlled by a third party, maximum compatibility is achieved by writing either .cjs or .mjs files as appropriate, and not .js files.

If neither package is concerned with backwards compatibility, writing ES modules into a .js file can be fine, but writing commonjs modules into a .js file in a directory whose package.json is controlled by a third party (e.g. another package) is not generally going to be forwards-compatible.

See also https://github.com/ember-cli/ember-cli/pull/10053#issue-1412217269

Co-authored-by: Robert Jackson rjackson@linkedin.com

hjdivad commented 1 year ago

cc @rwjblue

hjdivad commented 1 year ago

@ef4

I'd request a review but I guess I don't have commit to this repo. Anyhoo LMK if you're generally +1, want to see any changes &c.

ef4 commented 1 year ago

Looks good, but can we land the ember-cli PR so we don't need to install that branch?

rwjblue commented 1 year ago

Landed https://github.com/ember-cli/ember-cli/pull/10053, and updated this PR to just use ember-cli/ember-cli master.

hjdivad commented 1 year ago

@ef4 ember-cli PR landed and this one updated; this PR should be good to merge.

LMK if you'd like to see any other changes.

rwjblue commented 1 year ago

@ef4 - I think everything's been resolved here (the ember-cli change has landed, and is included in ember-cli@4.9.0-beta.0), anything else needed here for merge+release?

ef4 commented 1 year ago

This is released in 2.5.0