We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// entry.js (async () => { if(isLegacyBrowser()) await import("./polyfills?legacy"); else await import(/* webpackMode: "eager" */ "./polyfills"); await import(/* webpackMode: "eager" */ "./app"); })();
// polyfills.js import "core-js"; import "regenerator-runtime";
// webpack.config.js // ... module.rules: [ { test: /\.js$/, include: [ path.resolve(__dirname, "src") ], oneOf: [{ resourceQuery: "?legacy", loader: "babel-loader", options: { useBuiltIns: "entry". browserslistEnv: "legacy" } }, { loader: "babel-loader", options: { useBuiltIns: "entry". browserslistEnv: "modern" } }] } ]
But this would only handle polyfills and not transpiling...
If you want to handle transpiling too, you have to compile your app twice in different modes.
Often people just create two webpack config and compile twice, but it's also possible to use layers for that:
// webpack.config.js entry: { modern: { import: "./app", layer: "modern" }, legacy: { import: "./app", layer: "legacy" }, }, module.rules: [ { test: /\.js$/, include: [ path.resolve(__dirname, "src") ], oneOf: [{ issuerLayer: "legacy", loader: "babel-loader", options: { useBuiltIns: "usage". browserslistEnv: "legacy" } }, { issuerLayer: "modern", loader: "babel-loader", options: { useBuiltIns: "usage". browserslistEnv: "modern" } }] }, { test: /\.css$/, layer: "shared" // best switch the layer to compile parts only once // layer is inherited from parent otherwise } ]
or
// webpack.config.js module.rules: [{ resourceQuery: "?legacy", layer: "legacy" }]
Originally posted by @sokra in webpack/webpack#13241 (comment)
The text was updated successfully, but these errors were encountered:
It is old, but I still getting questions how developers should do it
Sorry, something went wrong.
snitin315
No branches or pull requests
But this would only handle polyfills and not transpiling...
If you want to handle transpiling too, you have to compile your app twice in different modes.
Often people just create two webpack config and compile twice, but it's also possible to use layers for that:
or
Originally posted by @sokra in webpack/webpack#13241 (comment)
The text was updated successfully, but these errors were encountered: