emberjs / ember-cli-babel

Ember CLI plugin for Babel
MIT License
153 stars 120 forks source link

useBuiltIns not working #166

Open simonihmig opened 7 years ago

simonihmig commented 7 years ago

Is useBuiltIns supposed to work here?

I guess no, because the polyfill is imported using ember-cli, so there is no import "babel-polyfill"; statement that this babel plugin is looking for, if I correctly understand that. Reducing the needed polyfill parts is probably tackled by https://github.com/babel/ember-cli-babel/pull/142, not using the useBuiltIns option, right?

If that is the case, this option should probably removed from the Readme, or mention that this is not working!?

houfeng0923 commented 4 years ago

useBuiltIns still can't work in 2020

nickschot commented 1 year ago

Still seems to be a problem with ember-cli-babel 8 (embroider safe) w/ core-js 3. Attempting to use useBuiltIns: 'usage' will add the imports, but gives a runtime error that the core-js files can't be found.

Trying to look into it a bit further...

I think useBuiltIns: 'entry' is basically a no-op at the moment? It seems to keep the core-js/stable (or whatever) import in-place which will import all the polyfills, meaning it's not run properly.

When I use core-js-builder with our browser targets I get a significantly smaller set of polyfills. I guess using that wrapped in a webpack plugin or whatever could be a temporary alternative to useBuiltIns: 'entry'.

'usage' would however probably be the more ideal solution...

andreyfel commented 4 weeks ago

I was able to make useBuiltIns: 'entry' work using ember-auto-import's feature allowAppImports: https://github.com/embroider-build/ember-auto-import/tree/main?tab=readme-ov-file#app-imports

This feature allows ember-auto-import to take over the control over certain files or directories in the app. Since ember-auto-import is using Webpack under the hood and not using ember-cli-babel, it allows us to use Babel's useBuiltIns feature.

The algorithm is the following: