Migrating from v1 to v2 #248
Replies: 4 comments 4 replies
-
Beta Was this translation helpful? Give feedback.
-
Additional example webpack@5 upgrade PRs: |
Beta Was this translation helpful? Give feedback.
-
Hi @joeldenning , I wrote a shared library and used it in another app. Both are following the webpack single spa config. I am facing the issue - I stuck me several days already so any help or hint so that I can overcome this issue. Sorry if this is not the right channel to ask this question. Thanks and regards, |
Beta Was this translation helpful? Give feedback.
-
@joeldenning @tam81 I am also facing same problem. I have created a utility module using single-spa and using the utility-module inside my single-spa application. While running the test using jest. I am getting error |
Beta Was this translation helpful? Give feedback.
-
Steps to upgrade
[email protected] release
Webpack 5 announcement post
webpack-config-single-spa
orts-config-single-spa
. Upgrade them to the new version.# DO NOT run all of these in your project. Only run the commands that apply to your project. npm install --save-dev webpack-config-single-spa@latest npm install --save-dev webpack-config-single-spa-ts@latest npm install --save-dev webpack-config-single-spa-react@latest npm install --save-dev webpack-config-single-spa-react-ts@latest npm install --save-dev ts-config-single-spa@latest
Upgrade all webpack loaders and webpack plugins that are dependencies in your package.json. Loaders are dependencies whose names often end with
-loader
. Plugins are dependencies whose names often includewebpack-plugin
.Update your package.json
scripts
. All instances ofwebpack-dev-server
should be replaced withwebpack serve
. All instances of--env.thing
should be replaced with--env thing
. You can remove the=true
from any--env
parts of webpack commands, as webpack 5 defaults it to true without the=true
.Remove
src/set-public-path.js
from your repository, if you haven't already. Webpack public path is now set via webpack plugin, so the set-public-path.js file is unnecessary.Remove
systemjs-webpack-interop
,css-loader
, andstyle-loader
, from your project, as they are now included in webpack-config-single-spa as a dependency.In your root config, upgrade systemjs, single-spa, and import-map-overrides. Delete the
named-exports.min.js
file, as it's not needed in newer versions of systemjs.Optional steps
Upgrade webpack-merge
Then in your webpack config, change how you import webpack-merge:
Then change how you call the webpack merge function:
If you're overriding webpack
module.rules
, consider usingmergeWithRules
to avoid duplicate rules. ExampleSee https://github.com/survivejs/webpack-merge and https://github.com/survivejs/webpack-merge/blob/develop/CHANGELOG.md#503--2020-07-06 for more info.
Upgrading root config
If you created your root config a long time ago, a lot has changed in both the create-single-spa v1 and v2 releases since then. Root configs now use
webpack-config-single-spa
.Now update your webpack.config.js, to match this template. Here's an example.
style-loader and css-loader issues
If you run into issues with style-loader/css-loader, it may be caused by duplicate copies of the libraries - one in webpack-config-single-spa and one in your project. To solve, tell webpack to use the version in webpack-config-single-spa, by using
require.resolve()
Stuck?
Comment here, or in the #general channel in our slack workspace to ask questions.
Beta Was this translation helpful? Give feedback.
All reactions