-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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-plugin-transform-es2015-modules-umd does not produce ES3 compatible modules #4799
Comments
I tried chaining |
Most likely didn't work because plugins run before presets. Not a long-term fix, but have y'all tried switching the order of the presets in Presets run last to first (yes, super confusing), so Edit: Tested that theory locally - unfortunately doesn't resolve the issue. |
The commonjs transform actually has hacks specifically to deal with this issue: https://github.com/babel/babel/blob/de46827/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js#L265-L270 |
@Kovensky Good catch. It looks like disabling the UMD transform addresses the issue, so we may (unfortunately) need similar hacks in there until the bigger issue is resolved |
@Blesh For the time being, you can use the {
"plugins": ["transform-es2015-modules-umd"],
"presets": ["es3", "es2015"],
"passPerPreset": true
} |
that seems to have done the trick, thanks @DrewML |
I'm having a similar issue with sometimes not getting |
* Switch to es3 preset for babel so that it runs last. Plugins run before presets and presets run in reverse order. Also, we ran into a weird bug in babel that causes `default` not to be quoted in some cases (babel/babel#4799) which we've worked around here. * Restore the es-shims for tests and the ie8 fallback script. * Do a null-check around `Player.players`. * use more round fractions (like 0.5 and 1) to avoid rounding issues.
Your example appear to be working now. |
Input Code
a.js:
b.js:
Babel Configuration (.babelrc, package.json, cli command)
Expected Behavior
The keyword
default
is not valid in ES3 and must always be quoted. For both a default export of a function and the import of a default it seems the plugin produces unquoteddefault
in some code positions.a.js
b.js
Current Behavior
When exporting a function as default, it gets emitted as
exports.default =
instead ofexport["default"] =
.a.js
When importing a default from another module, the interop require default includes an object literal with a
default
key instead of"default"
:b.js
Possible Solution
Always quote
default
.Context
It is causing Babel to produce invalid ES3 code, which is not ideal when trying to generate ES3 compatible modules.
Your Environment
The text was updated successfully, but these errors were encountered: