embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
334 stars 136 forks source link

Babel plugin runs on v2 addon code where it shouldn't #1462

Open simonihmig opened 1 year ago

simonihmig commented 1 year ago

Context:

Reproduction:

While debugging, I found:

ef4 commented 1 year ago

Under embroider there is only one babel config during the final stage app build. So it's true that a transform added to the app is also going to run over the addons. In general babel plugins should try not to break code that doesn't need the feature they add.

We offer skipBabel to disable all babel transpilation of a given package, but that is rather extreme as you also lose preset-env, etc.

Perhaps the cached decorator polyfill could behave more like @babel/runtime, which has the option to emit an absolute or relative path in the import, so that it's resolvable regardless of which package it appear in.