You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario: using Babel with Webpack X and targeting Browser Y. Browser Y supports syntax Z, but Webpack X doesn't.
@babel/preset-env will not compile syntax Z, and then Webpack will throw about it saying "unexpected token; you might need an appropriate loader to handle this file". Users are surprised/annoyed, because they expected Babel to properly handle modern syntax.
Describe the solution you'd like
babel-loader should pass through .caller the webpack/acorn version, and @babel/preset-env should have data to know which plugins to compile. This can also apply to other tools, but I have always only seen this problem reported by people using webpack.
We can consider console.warning if we have to enable a plugin just because Webpack needs it, and not because the target browser needs it.
Describe alternatives you've considered
We could allow setting webpack: "XXX" in targets, but it requires users to explicitly set it rather than being automatic.
Documentation, Adoption, Migration Strategy
Nothing, users will just see less confusing errors :)
💻
What problem are you trying to solve?
Scenario: using Babel with Webpack X and targeting Browser Y. Browser Y supports syntax Z, but Webpack X doesn't.
@babel/preset-env
will not compile syntax Z, and then Webpack will throw about it saying "unexpected token; you might need an appropriate loader to handle this file". Users are surprised/annoyed, because they expected Babel to properly handle modern syntax.Describe the solution you'd like
babel-loader
should pass through.caller
the webpack/acorn version, and@babel/preset-env
should have data to know which plugins to compile. This can also apply to other tools, but I have always only seen this problem reported by people using webpack.We can consider
console.warn
ing if we have to enable a plugin just because Webpack needs it, and not because the target browser needs it.Describe alternatives you've considered
We could allow setting
webpack: "XXX"
in targets, but it requires users to explicitly set it rather than being automatic.Documentation, Adoption, Migration Strategy
Nothing, users will just see less confusing errors :)
Related: #14280
The text was updated successfully, but these errors were encountered: