embroider-build / ember-auto-import

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

`esmodules: true` config/targets #495

Open mehulkar opened 2 years ago

mehulkar commented 2 years ago

In an ember app with config/targets.js exporting this:

module.exports = { esmodules: true }

ember-auto-import@2 is not able to build the app. The issue seems to be that the config is passed to Webpack: https://github.com/ef4/ember-auto-import/commit/991974795f5bbd63d276094a53b273a5880013f0

Similarly, this config also does not work:

module.exports = { esmodules: true, browsers: [] }

because webpack then gets an empty string query for targets: (browserslist:) here:

https://github.com/ef4/ember-auto-import/blob/24b5eef87078cdbbcb54c6c93d0ef2e36e63eaef/packages/ember-auto-import/ts/webpack.ts#L153

ef4 commented 2 years ago

I think perhaps we can use getTarget from https://babeljs.io/docs/en/babel-helper-compilation-targets to normalize the config/targets.js value into something would work here.