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
Provide an ESM build #75
Conversation
import * as babel from "@babel/core"; | ||
const { types: t } = babel.default || babel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because Rollup's interop is incompatible with Node.js's behavior (rollup/plugins#635)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rollup/plugins#838 will make it possible to avoid doing this, if it will get merged.
test/esm/index.mjs
Outdated
import esShims from "babel-plugin-polyfill-es-shims"; | ||
import regenerator from "babel-plugin-polyfill-regenerator"; | ||
|
||
assert.equal(typeof corejs2, "function"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be an object with { default: function, __esModule: true }
if we imported the CJS file.
I tried using this in an ESM build of the |
Gulpfile.js
Outdated
}), | ||
rollupNodeResolve({ | ||
extensions: [".ts", ".js", ".mjs", ".cjs", ".json"], | ||
browser: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Why do we need to resolve against browser fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now provide two bundles for @babel/helper-define-polyfill-provider
: one for Node.js (which accesses the filesystem) and one for the browser (which doesn't).
Ohh it's finally green! |
I'm slowly converting the
babel/babel
repository to ESM, and it's a bit annoying that these packages require the@babel/core
peerDependency because they fail when testing an ESM build of@babel/core
.Providing an ESM build fixes the problem, and it also gives us the possibility of testing real-world ESM Babel plugins.
CI will fail until we release babel/babel#13000.