Skip to content
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

[preset-env] Automatically compile features not supported by webpack, even if they are supported by the browserslist target #14963

Open
1 task
nicolo-ribaudo opened this issue Sep 21, 2022 · 0 comments

Comments

@nicolo-ribaudo
Copy link
Member

💻

  • Would you like to work on this feature?

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.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 :)

Related: #14280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants