From d914fb0cfcb57e7c7413087335c7758cb439db53 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 30 May 2023 23:56:38 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"Use=20ES=20modules=20and=20dynamic=20?= =?UTF-8?q?import=20for=20Webpack=20latest=20builds=20(=E2=80=A6=20(#16679?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "Use ES modules and dynamic import for Webpack latest builds (#16620)" This reverts commit 7b350e31dd9a313d1023d2049d9513f58d38e8de. --- .browserslistrc | 6 ------ build-scripts/bundle.cjs | 1 - build-scripts/webpack.cjs | 5 ++--- test/webpack.config.js | 7 +------ 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index 516fec9cec..86481f8e08 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -10,12 +10,6 @@ supports es6-module-dynamic-import not Safari < 13 not iOS < 13 -# Exclude KaiOS, QQ, and UC browsers due to lack of sufficient feature support data -# Babel ignores these automatically, but we need here for Webpack to output ESM with dynamic imports -not KaiOS > 0 -not QQAndroid > 0 -not UCAndroid > 0 - # Exclude unsupported browsers not dead diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index f840f21762..a6d14f18c8 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -77,7 +77,6 @@ module.exports.htmlMinifierOptions = { module.exports.terserOptions = ({ latestBuild, isTestBuild }) => ({ safari10: !latestBuild, ecma: latestBuild ? 2015 : 5, - module: latestBuild, format: { comments: false }, sourceMap: !isTestBuild, }); diff --git a/build-scripts/webpack.cjs b/build-scripts/webpack.cjs index 418037d9da..58cc184ca8 100644 --- a/build-scripts/webpack.cjs +++ b/build-scripts/webpack.cjs @@ -41,7 +41,7 @@ const createWebpackConfig = ({ return { name, mode: isProdBuild ? "production" : "development", - target: `browserslist:${latestBuild ? "modern" : "legacy"}`, + target: ["web", latestBuild ? "es2017" : "es5"], // For tests/CI, source maps are skipped to gain build speed // For production, generate source maps for accurate stack traces without source code // For development, generate "cheap" versions that can map to original line numbers @@ -163,7 +163,6 @@ const createWebpackConfig = ({ }, }, output: { - module: latestBuild, filename: ({ chunk }) => !isProdBuild || isStatsBuild || dontHash.has(chunk.name) ? "[name].js" @@ -197,7 +196,7 @@ const createWebpackConfig = ({ : undefined, }, experiments: { - outputModule: true, + topLevelAwait: true, }, }; }; diff --git a/test/webpack.config.js b/test/webpack.config.js index ad593b58aa..20e1e163e3 100644 --- a/test/webpack.config.js +++ b/test/webpack.config.js @@ -1,13 +1,8 @@ import webpack from "../build-scripts/webpack.cjs"; -const config = webpack.createAppConfig({ +export default webpack.createAppConfig({ isProdBuild: false, latestBuild: true, isStatsBuild: false, isTestBuild: true, }); - -// instant-mocha forces a CJS library, so cannot output ESM -config.output.module = false; - -export default config;