Skip to content

Conversation

@internettrans
Copy link
Member

This is a WIP.

The steps that each project needs to take to upgrade:

  1. yarn add webpack@latest webpack-cli@latest webpack-dev-server@https://github.com/webpack/webpack-dev-server#v4
  2. Change package.json start script from webpack-dev-server to webpack --serve

We should probably wait for webpack-dev-server@4 before releasing this because we need the fix in webpack/webpack-dev-server#2839, which will be released once webpack/webpack-dev-server#2592 is merged and released.

We should also look into why the devServer.client.port option has to be specified - ideally it wouldn't be.

libraryTarget: "system",
path: path.resolve(process.cwd(), "dist"),
jsonpFunction: `webpackJsonp_${opts.projectName}`,
// jsonpFunction: `webpackJsonp_${opts.projectName}`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option was removed. Not sure if it was renamed to something else. We should look into this more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I read awhile ago, it’s based on the name field in package.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks I'll switch to that.

jsonpFunction: `webpackJsonp_${opts.projectName}`,
// jsonpFunction: `webpackJsonp_${opts.projectName}`,
devtoolNamespace: `${opts.projectName}`,
publicPath: "",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack@5 has an "auto" public path option. unfortunately it doesn't work with loading via systemjs right now. Since "auto" is the new default for publicPath, I had to specify the public path as an empty string so that the public path comes from systemjs-webpack-interop instead of the broken "auto" functionality

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes auto incompatible with systemJs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't look into it

],
},
devtool: "sourcemap",
devtool: "source-map",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack 5 renamed this

"Access-Control-Allow-Origin": "*",
},
disableHostCheck: true,
firewall: false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableHostCheck: true,
firewall: false,
client: {
port: 8080,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sockPort was removed - this is the equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's much much better not to have to hard code the port here, but let the user specify it via CLI arg - we likely will need to fix webpack-dev-server in order for it to support this. It's one of the things holding up this PR

new BundleAnalyzerPlugin({
analyzerMode: webpackConfigEnv.analyze ? "server" : "disabled",
}),
new UnusedFilesWebpackPlugin({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin doesn't work with webpack 5 (rip). See tomchentw/unused-files-webpack-plugin#39

@internettrans
Copy link
Member Author

The main thing holding up this PR is that it relies on webpack-dev-server@4, which is unreleased

@internettrans
Copy link
Member Author

Ah it looks like [email protected] was just released! I'll try to get this PR ready to merge then - there is still the issue of having to specify port.

@internettrans internettrans changed the base branch from master to 2.x November 28, 2020 00:59
@internettrans
Copy link
Member Author

This is now fully updated and the tests should (hopefully) pass - the only thing remaining is the port issue. I plan on making a pull request to webpack-dev-server fixing it.

@internettrans
Copy link
Member Author

The webpack-dev-server issue is here: webpack/webpack-dev-server#2873

@internettrans
Copy link
Member Author

I created a PR to webpack-cli which will resolve the port issue: webpack/webpack-cli#2147

Thumbs up on the PR are appreciated - webpack-cli is a hard project to get code merged into.

@internettrans
Copy link
Member Author

I think we can merge this and publish a beta of create-single-spa with it, noting the caveat when using default port.

I'll mark this as ready for review

@internettrans internettrans marked this pull request as ready for review November 30, 2020 01:18
@internettrans internettrans merged commit efb694b into 2.x Nov 30, 2020
@internettrans internettrans deleted the webpack-5 branch November 30, 2020 01:37
@internettrans
Copy link
Member Author

This is released in https://github.com/single-spa/create-single-spa/releases/tag/v2.0.0-beta.0, which includes instructions for upgrading existing projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants