Open EthianWong opened 2 years ago
We encourage library authors not to distribute code that uses untranspiled ES6 features (other than modules) for this reason. Consumers of your library should not have to transpile your ES6 code, any more than they should have to transpile your CoffeeScript, ClojureScript or TypeScript. ------- @rollup/plugin-babel
The rollup officials not recommend use untranspiled ES6 features to the module, but some authors don't think so, such as debug
. So should microbundle
allow developers to choose whether to enable babel for node_modules when they use inline dependencies? Currently mcicorbundle
specifies exclude: 'node_modules/**'
which leaves no way for developers to change.
@developit @rschristian How do you feel about this?
This makes a lot of sense in my opinion specifically for inlined dependencies. If the inlined dependency is not transpiled, this means the application needs to re-transpile a library built by microbundle. Wouldn't that make using non-modern mode for this library irrelevant, if it contains a mix of transpiled and untranspiled code in the bundle?
FWIW I am in favor of this. My preference would be to run the "modern to legacy" portion of the JS transpilation on bundles, rather than on source files, similar to the setup described in this diagram: https://github.com/developit/optimize-plugin#how-does-this-work
Same issue here, such as query-string release es6 code to npm : https://github.com/sindresorhus/query-string/issues?q=es5
may I ask what's the solution for this? Meet the same issue and I want to transpile the specific package in node_modules.
There's no built-in/automatic solution for the moment, but you can, post-build, run Babel over your bundles to remove any erroneous modern features.
Now microbundle is use
exclude: 'node_modules/**'
to create babel config, I think it's reasonable when not inline dependencies. But if use inline dependencies... this options maybe is weird?Then add
foo
module todevDependencies
.Result:
If i use inline dependencies mean i hope it's part of mine module, my modules arrow function has compile (it's right) but
foo
modules has nothing change.Maybe should not set
exclude: 'node_modules/**'
when use inline dependencies?