-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Progress tracked at https://github.com/babel/babel/projects/16
Feature Request
Is your feature request related to a problem?
Would like to be able to consume babel packages directly as modules (as they are written), instead of just cjs. (In my case, may want to import Babel itself into something like snowpack/vite which tries to only support esm). This would be for anything trying to use babel for tooling like the repl/etc so not a common usecase.
Also good that we dogfood what other packages/libraries are doing, even though we aren't really a tool for the browser it would be good to attempt to understand the issues with doing all this anyway.
Describe the solution you'd like
⚠️ EDIT: See #11701 (comment)
Use package exports. When building we change our config to do modules: false
in preset-env. Currently we do "main": "lib/index.js",
for most packages.
Could output a whole folder like dist
or module
instead of lib
or output .mjs
in the same lib
folder.
{
"main": "./lib/main.js",
"module": "./lib/module.mjs",
"exports": {
".": {
"import": "./lib/module.mjs",
"default": "./lib/main.js"
},
"./other": {
"import": "./lib/other.mjs",
"default": "./lib/other.js"
}
}
}
Describe alternatives you've considered.
Don't think there's an alternative other than consuming the source via github which is difficult because this is a monorepo. We only publish cjs.