Skip to content

Commit

Permalink
Disable HMR in ES modules when outputSystemJS option is omitted (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning authored Feb 4, 2025
1 parent f129c87 commit 011ed65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-ghosts-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-config-single-spa": patch
---

Fix bug where HMR was mistakenly enabled when outputSystemJS option was omitted
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function webpackConfigSingleSpa(opts) {

let HtmlWebpackPlugin = opts.HtmlWebpackPlugin || _HtmlWebpackPlugin;

const outputSystemJS = !!opts.outputSystemJS;

return {
mode: isProduction ? "production" : "development",
entry: path.resolve(
Expand All @@ -51,7 +53,7 @@ function webpackConfigSingleSpa(opts) {
path: path.resolve(process.cwd(), "dist"),
uniqueName: opts.projectName,
devtoolNamespace: `${opts.projectName}`,
publicPath: opts.outputSystemJS ? "" : "auto",
publicPath: outputSystemJS ? "" : "auto",
},
module: {
rules: [
Expand Down Expand Up @@ -123,7 +125,7 @@ function webpackConfigSingleSpa(opts) {
},
},
allowedHosts: "all",
hot: opts.outputSystemJS,
hot: outputSystemJS,
},
externals: opts.orgPackagesAsExternal
? ["single-spa", new RegExp(`^@${opts.orgName}/`)]
Expand All @@ -132,7 +134,7 @@ function webpackConfigSingleSpa(opts) {
new BundleAnalyzerPlugin({
analyzerMode: webpackConfigEnv.analyze ? "server" : "disabled",
}),
opts.outputSystemJS &&
outputSystemJS &&
new SystemJSPublicPathPlugin({
systemjsModuleName: `@${opts.orgName}/${opts.projectName}`,
rootDirectoryLevel: opts.rootDirectoryLevel,
Expand All @@ -155,7 +157,7 @@ function webpackConfigSingleSpa(opts) {
extensions: [".mjs", ".js", ".jsx", ".wasm", ".json"],
},
experiments: {
outputModule: !opts.outputSystemJS,
outputModule: !outputSystemJS,
},
};
}

0 comments on commit 011ed65

Please sign in to comment.