question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Babel 7 present env using useBuiltIns: usage does not transpile AMD 'define' properly

See original GitHub issue

Bug 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:open
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
chaoyzengcommented, Oct 22, 2018

Is there an existing feature request for supporting AMD?

0reactions
nicolo-ribaudocommented, Mar 4, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found