Skip to content

Commit

Permalink
Default to output native modules. Add outputSystemJS option. (#412)
Browse files Browse the repository at this point in the history
* Default to output native modules. Add outputSystemJS option.

* Improve changeset
  • Loading branch information
joeldenning authored Sep 30, 2024
1 parent 60a7358 commit f9edeef
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .changeset/gentle-ducks-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
"webpack-config-single-spa": major
---

Output to native ES modules by default. Add new outputSystemJS option.

## Upgrading

To upgrade without switching to native ES modules, add the `outputSystemJS` option to your webpack.config.js:

```js
const { merge } = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa");

module.exports = (webpackConfigEnv, argv) => {
const defaultConfig = singleSpaDefaults({
orgName: "org",
projectName: "project",
webpackConfigEnv,
argv,

// This is the new option that preserves backwards compatibility
outputSystemJS: true,
});

return merge(defaultConfig, {
// modify the webpack config however you'd like to by adding to this object
});
};
```

To switch to native ES modules, see the full migration guide on single-spa.js.org
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function webpackConfigSingleSpa(opts) {
),
output: {
filename: `${opts.orgName}-${opts.projectName}.js`,
libraryTarget: "system",
libraryTarget: opts.outputSystemJS ? "system" : "module",
path: path.resolve(process.cwd(), "dist"),
uniqueName: opts.projectName,
devtoolNamespace: `${opts.projectName}`,
Expand Down Expand Up @@ -142,5 +142,8 @@ function webpackConfigSingleSpa(opts) {
resolve: {
extensions: [".mjs", ".js", ".jsx", ".wasm", ".json"],
},
experiments: {
outputModule: !opts.outputSystemJS,
},
};
}
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9edeef

Please sign in to comment.