embroider-build / ember-auto-import

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

Can't enable babel plugin to transpil auto-imported deps #482

Closed romgere closed 2 years ago

romgere commented 2 years ago

I'm working on a add-on wich use some npm dep with auto-import (v1.11.3)

One deps use es12 numeric separator in last release, when I'm trying to update, the build ends with "module parse failed" error due to the statement with the numeric separator syntax.

I tried to fix this issue by :

But still the same issue 😕

I was thinkink that ember-auto-import used babel & should take into account the babel plugin mentionned above ? or did I missed something ?

Here is a fresh app (not an add-on) reproducing the issue : https://github.com/romgere/test-auto-import-babel

ef4 commented 2 years ago

Thanks for sharing a reproduction.

Your reproduction is using ember-auto-import 1.11.3. I updated it to the current release (2.2.4) and it works.

ef4 commented 2 years ago

I should clarify though:

Out of the box, we only support standards-compliant javascript in third-party dependencies. Since numeric separators are part of the ES2021 standard, they're supported if you have new enough dependencies.

If you really wanted to apply custom babel to third-party code you can, but you need to do it directly by putting your own module.rules in ember-auto-import's webpack config, applying babel loader, etc. You can tell the built-in babel to ignore some packages using the skipBabel option so that your custom babel can be responsible for those ones.

romgere commented 2 years ago

Thx a lot @ef4 for the fast answer 🙏🏻 I'll wait to be able to update to auto-import v2 to update the concerned deps.

tannerjt commented 2 years ago

We're currently tied to ember-auto-import v1. One of our node_modules dependencies uses import.meta which throws the following error from ember-auto-import/babel-loader:

Support for the experimental syntax 'importMeta' isn't currently enabled

and prompts the following resolve:

Add @babel/plugin-syntax-import-meta (https://git.io/vbKK6) to the 'plugins' section of your Babel config to enable parsing.

Attempting to add this module to skipBabel did not appear to get applied. How would I inform ember-auto-loader to ignore this issue?