Cannot set core-js version for helper-only transformation in `@babel/tranform-runtime`
See original GitHub issueFeature Request
Is your feature request related to a problem? Please describe.
Basically we are trying to resolve this issue in @vue/babel-preset-app:
https://github.com/babel/babel/issues/6628 How can we write ES20xx and ship the smallest amount of code (for a given target environment)?
To be more specific, this item:
- babel helpers: reference the same helpers instead of recreating per file (either via /packages/babel-plugin-transform-runtime@
7.0
#options
- To achieve that we need to combine
@babel/preset-env
with@babel/transform-runtime
, and the latter one is only used to do helper transformation. - The default runtime has a blocking issue though, see https://github.com/babel/babel/issues/7597
- So to circumvent it we have to use
@babel/runtime-corejs2
. I know it’s not the best solution but it’s an acceptable compromise/tradeoff in practice. - Before beta.56 we were able to disable
polyfills
option while still referring the helper functions to@babel/runtime-corejs2
. - But after this commit,
polyfills
option is removed because it is now the default behavior. - An unintended consequence is that we can no longer point
helpers
to any other runtime package without introducing core-js polyfills along with it.
Describe the solution you’d like
Bring back the polyfills
option, allowing the user to opt-out it while still being able to specify a core-js version for helpers.
Describe alternatives you’ve considered N/A
Teachability, Documentation, Adoption, Migration Strategy N/A
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
babel/plugin-transform-runtime
A plugin that enables the re-use of Babel's injected helper code to save on codesize.
Read more >babel 7.x - Can't resolve 'core-js/modules/es.array.concat'
To resolve this error, you can downgrade the core-js version to 2.5.7. This version produces correct catalogs structure, with separate ES6 ...
Read more >core-js
Standard library. Latest version: 3.26.1, last published: a month ago. Start using core-js in your project by running `npm i core-js`.
Read more >How babel preset-env, core-js, and browserslistrc work ...
@babel/preset-env is a collection of babel plugins to transform modern ... We're targeting a new Firefox version in .browserslistrc , so you ...
Read more >Babel polyfill is dead. Long live core-js! - Alex Bogovich
Lets see how to set core-js version and combine it with babel without ... to core-js@2 and cannot provide smooth migration to core-js@3....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As a workaround, you can use https://github.com/tleunen/babel-plugin-module-resolver to alias
@babel/runtime
->@babel/runtime-corejs2
I’m closing this issue, since it’s possible to transpile
@babel/runtime
with@babel/preset-env
to add polyfills.