From f67f7c0f0b8e654a0b2da6aa3a57d2b65827acb3 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Wed, 31 May 2023 16:47:00 -0700 Subject: [PATCH] [js/web] disable node fallback in webpack (#16166) ### Description disable webpack's polyfill for node's `global`, `__filename` and `__dirname` in web build. This will confuse emscripten generated environment detection. see https://webpack.js.org/configuration/node/ --- js/web/webpack.config.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/web/webpack.config.js b/js/web/webpack.config.js index 84ab9bcae8..cedff6a9a5 100644 --- a/js/web/webpack.config.js +++ b/js/web/webpack.config.js @@ -49,7 +49,7 @@ function defaultTerserPluginOptions(target) { passes: 2 }, mangle: { - reserved: ["_scriptDir","startWorker"] + reserved: ["_scriptDir", "startWorker"] } } }; @@ -111,6 +111,7 @@ function buildConfig({ filename, format, target, mode, devtool, build_defs }) { }] }, mode, + node: false, devtool }; @@ -268,8 +269,9 @@ function buildTestRunnerConfig({ type: 'asset/source' }] }, - mode: mode, - devtool: devtool, + mode, + node: false, + devtool, }; if (mode === 'production') {