Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: Use webpack 5 by default #48

Merged
merged 1 commit into from
Oct 24, 2020
Merged

pkg: Use webpack 5 by default #48

merged 1 commit into from
Oct 24, 2020

Conversation

ntucker
Copy link
Owner

@ntucker ntucker commented Oct 15, 2020

Since webpack 5 is final, let's use it as primary target. Webpack 4 will still be supported for the foreseeable future.

Build times

Done on examples/typescript project (with antd). Machine: Threadripper 2950x, Samsung 970 Pro, WSL2 on Win10.

4:

Cold prod build: ~28 seconds
Hot prod build: ~17 seconds
Aggregate size: 327kb gzip
Entry size (vendor non-react): 67kb gzip

5:

Cold prod build: ~17 seconds
Hot prod build: ~5 seconds
Aggregate size: 298kb gzip
Entry size (vendor non-react): 53kb gzip

Improvement:

  • 3.4x faster hot builds
  • 65% faster cold builds
  • 26% Entrypoint size reduction

Must fix:

Warnings:

Future work:

  • html-webpack-plugin v5 - drops v4 webpack support
  • css-loader v5 - drops webpack 4 support

Other changes:

  • Don't hoist storybook things so it doesn't break with plugin version mismatches

Testing:

  • both dev, prod, analyze commands
  • Tested on webpack 4 and 5

@ljharb
Copy link
Collaborator

ljharb commented Oct 15, 2020

This isn't a good idea unless we can restore "everyone else's" behavior of polyfilling node core modules, which is required to correctly bundle node modules.

@ntucker
Copy link
Owner Author

ntucker commented Oct 15, 2020

@ljharb Yeah, I saw that in people's reactions to webpack 5. I'll add a TODO item here to incorporate that behavior so this doesn't land without solving that problem.

@ntucker ntucker marked this pull request as draft October 15, 2020 23:49
@ntucker ntucker requested a review from ljharb October 16, 2020 04:36
@ntucker ntucker force-pushed the pkg/webpack branch 5 times, most recently from 2d46bd4 to 15b4ecd Compare October 23, 2020 21:56
@ntucker ntucker marked this pull request as ready for review October 23, 2020 22:00
@ntucker ntucker requested a review from ljharb October 23, 2020 22:00
@@ -184,6 +186,7 @@ export default function makeBaseConfig({
'node_modules',
],
extensions: ['.js', '.ts', '.tsx', '.scss', '.json'],
alias: webpack.version.startsWith('4') ? {} : NODE_ALIAS,
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems more reliable to use the semver library here, but i suppose by the time webpack 40 comes out, this code will be different :-p

Copy link
Owner Author

Choose a reason for hiding this comment

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

exactly. deprecating 4 support will happen long before then :P

pkg: Use sass instead of node-sass

fix: Make devserver static asset serving consistent

BREAKING CHANGE: Dev mode static assets /assets/${buildDir} ->
/${buildDir}

(By default this means /assets/dist/ -> /dist/)

pkg: html plugin fixes compat issue

fix: sass-loader filecache compat

pkg: Bump style-only-imports

fix: polyfill node builtins for web target

fix: More comprehensive node polyfill

pkg: Maintain 4 compatibilitly
@ntucker ntucker merged commit f1e6631 into master Oct 24, 2020
@ntucker ntucker deleted the pkg/webpack branch October 24, 2020 02:39
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.

2 participants