Babel 7 present env using useBuiltIns: usage does not transpile AMD 'define' properly
See original GitHub issueBug Report
Current Behavior Using babel 7 with present env with configuration “useBuiltIns: usage” then any amd modules that contain an instance method that needs to be polyfilled will not transpile correctly.
Modules that do NOT contain instance methods will transpile correctly.
When executing the broken module you will get:
Uncaught ReferenceError: define is not defined
Input Code I have set up a dummy project with minimum configuration to demonstrate the bug: https://github.com/chaoyzeng/babel-7-present-env-bug
just run the webpack dev server and load the webpage to see the console error.
Expected behavior/code All amd modules are treated the same regardless of the code that they contain.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
AMD modules with useBuiltIns not correctly implemented
I am using Babel with babel-preset-react and babel-preset-env in an environment where modules are managed by requirejs.
Read more >Confused about useBuiltIns option of @babel/preset-env ...
1) Do I need to use that useBuiltIns: "entry" option? Yes, if you want to include polyfills based on your target environment. TL;DR....
Read more >babel/preset-env
babel /preset-env` is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, ......
Read more >Complete Babel 7 Guide for Beginners | by OnlyKiosk Dev Tech
Babel/preset-env is the standard Babel 7 uses to translate ES6+ into ES5. In Babel 7 ... New syntax is not the only difference...
Read more >What you don't know about BabelJS preset-env - PerimeterX
The preset-env useBuiltins flag determines if babel should always add corejs polyfills, add them once per file or per usage of a particular ......
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
Is there an existing feature request for supporting AMD?
Even if Babel properly injected AMD dependencies for polyfills,
core-js
doesn’t provide AMD or UMD sources so it cannot work anyway.Unfortunately, you have to either load
core-js
(or another polyfill) with a<script>
tag or use a bundler such as Webpack.