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
Publish JS modules build to npm #8246
Comments
Hey @justinfagnani! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
Even if we published Babel without transpiling modules, it would still rely on node semantics to esolve dependencies (e.g. |
That's ok, many tools like unpkg.com with the ?module query param, or the Polymer build system support rewriting just the import specifiers. For future native support, there's the package-name-maps proposal which will let browsers use named imports. |
Babel's standard workflow is specifically Node >= LTS, so if browser usage of this is the primary driver, I suppose we could consider an ESM build of |
I agrre that 'in-browser' application would be a 'big win'. I am investigating another application scenario as well where Node would NOT be in the picture. An 'ESM build of @babel/standalone' would be great. I would be glad to help if I can. |
Also tracked by #11701. We'll do this in Babel 8. |
Feature Request
Is your feature request related to a problem? Please describe.
I'd like to load Babel in a browser using the native module system that all browsers now support. Babel seems to be only distributed as CJS though.
Describe the solution you'd like
Publish standard JS modules, probably to a separate modules/ folder of the packages, along with a
module
field in package.json pointing to modules/index.jsDescribe alternatives you've considered
There is no good solution for importing CJS into native modules. CJS can be build and bundled into script that's executable by browsers, but the semantics are different enough from standard JS modules that it isn't possible to reliably reconstruct the named exports of the original source. Since Babel is written as JS modules, hopefully the Flow compiler can simply strip out the non-standard syntax and output pure modules.
Teachability, Documentation, Adoption, Migration Strategy
Modules are standardized and supported in all current browsers. They are supported in node.js via the
esm
loader.Loading Babel in browsers without any build system, and importantly being compatible with libraries and applications trying to use only pure modules, would be a big win for Babel 7.
The text was updated successfully, but these errors were encountered: