Add --out-file-extension option to babel-cli#9144
Add --out-file-extension option to babel-cli#9144nicolo-ribaudo merged 6 commits intobabel:masterfrom
Conversation
|
It might be nicer to allow the config itself specify an output extension - then we could run twice, one with each config, to output for each extension (each of which has a different set of target environments) |
|
@ljharb I think so too so that you could use a single cli command and change the output extension based on some environment variable. I think this is a better starting point though since |
|
Small nit in the PR description:
Shouldn't the filenames be |
6b4ca53 to
cce3797
Compare
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11285/ |
Yeah, it should throw. WDYT about naming it |
cce3797 to
e12d5e5
Compare
9c84bae to
d5dc562
Compare
|
@nicolo-ribaudo Done d5dc562. Initially forgot to add a trailing newline to |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
It seems that it is working anyway?
|
I would love to see this PR merged since it will allow us to remove ugly shell scripts from our ATM we have a choice of either waiting until this feature gets merged or drop |
d5dc562 to
34db0a0
Compare
|
Is there something blocking a merge? Really looking forward to this shipping; so we can output separate {
"prepare:mjs": "BABEL_ESM=1 babel src -d . --out-file-extension .mjs",
"prepare:cjs": "babel src -d . --out-file-extension .cjs"
} |
34db0a0 to
dfa4a31
Compare
use existing methods from path module
dfa4a31 to
1415c95
Compare
JLHwung
left a comment
There was a problem hiding this comment.
Thanks! Docs is needed anyway.
Webpack 4 automatically prioritizes
foo.mjsoverfoo.jswhen resolvingimport foo from './foo'. With this change we can publish a flat package with esmodules and commonjs side by side that allows imports such asimport foo from package/barthat webpack can easily tree shake with help of esmodules.Settled on
out-file-extensionto be consistent with other flags (out-dir,out-fileetc.)Alternatives for flag name:
--output-file-extension--with-file-extensionShould I add a warning if both
--keep-file-extensionand--use-file-extensionare used?It throws now