Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chaoyzeng opened this issue Oct 17, 2018 · 6 comments

Comments

@chaoyzeng
Copy link

chaoyzeng commented Oct 17, 2018

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.

@babel-bot
Copy link
Collaborator

Hey @chaoyzeng! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@chaoyzeng chaoyzeng changed the title Babel 7 present env using useBuiltIns: usage does not transpile commonjs 'define' properly Babel 7 present env using useBuiltIns: usage does not transpile AMD 'define' properly Oct 17, 2018
@loganfsmyth
Copy link
Member

The useBuiltIns only supports CommonJS and ESM currently, so this is expected unfortunately.

@chaoyzeng
Copy link
Author

Is there an existing feature request for supporting AMD?

@loganfsmyth
Copy link
Member

Not that I know of. Generally AMD ends up getting treated as a bit of a second-class citizen compared to CommonJS and ESM. AMD is a much more limited format, and is harder to manipulate in transforms because it has so many pieces that have to work together.

@fbove
Copy link

fbove commented Mar 4, 2021

Is there any way to make this work?

@nicolo-ribaudo
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants