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

Webpack5 update [DRAFT] #10656

Closed
wants to merge 29 commits into from
Closed

Webpack5 update [DRAFT] #10656

wants to merge 29 commits into from

Conversation

raix
Copy link
Contributor

@raix raix commented Mar 6, 2021

Webpack 5 update
Includes the work listed in #9994

Additional changes:

  • persistent cache
  • upgrade to dev server ´v4 (still beta)
  • terser is now included in webpack

Known issues:

  • currently the WebpackManifestPlugin is commented out due to "path undefined" error (feel free to investigate)
  • It feels like webpack emits compile twice - triggers a re print out on the screen (might be due to hook behavior change - or some of the code I removed in that area - maybe rewrite?)

Things I wanted to do but left out:

  • extract loaders/plugins etc. into separate files to make the main webpack config clean / easier to read
  • allowed domains - we should allow configuration and wildcard support imho
  • print out performance stats of the build - really hard to track / compare build speeds - eg. detecting regression
  • fix the test suite or comment out failing tests - eg. the pnp test is currently failing on master not sure if this pr. makes things better or worse

Credit include @andriijas, @sebinsua and @jasonwilliams (let me know if I missed out on any)

Morten N.O. Henriksen and others added 20 commits January 27, 2021 19:36
* upstream/master:
  Update IMAGE_INLINE_SIZE_LIMIT docs (#10631)
  Publish
  Update CHANGELOG
  Prepare 4.0.3 release
  update immer to 8.0.1 to address vulnerability (#10412)
  Upgrade eslint-webpack-plugin to fix opt-out flag (#10590)
  Bump webpack-dev-server 3.11.0 -> 3.11.1 (#10312)
  tests: update test case to match the description (#10384)
  Publish
  Prepare 4.0.2 release
  Add opt-out for eslint-webpack-plugin (#10170)
  Add support for new BUILD_PATH advanced configuration variable (#8986)
  appTsConfig immutability handling by immer (#10027)
  Fix CI tests (#10217)
  docs: add missing override options for Jest config (#9473)
Add css-minimizer-webpack-plugin@1.1.5
Remove optimize-css-assets-webpack-plugin and postcss-safe-parser

References:
* https://webpack.js.org/plugins/css-minimizer-webpack-plugin/
@raix raix changed the title Webpack5 update Webpack5 update [DRAFT] Mar 6, 2021
@raix raix mentioned this pull request Mar 6, 2021
25 tasks
Morten N.O. Henriksen added 3 commits March 6, 2021 21:29
@rickihastings
Copy link

Hey, I noticed file-loader and url-loader are still used in this PR, however they are deprecated in Webpack 5 and can be replaced with asset modules.

@raix
Copy link
Contributor Author

raix commented Mar 11, 2021

Yep good catch! I'll see if I'll update in the weekend :)

@vjpr
Copy link

vjpr commented Mar 16, 2021

Could you publish updates to npm - would make testing easier...

I.e. Swap react-scripts to @raix/react-scripts

@kumarlachhani
Copy link

kumarlachhani commented Mar 17, 2021

currently the WebpackManifestPlugin is commented out due to "path undefined" error (feel free to investigate)

This error is raised from webpack-manifest-plugin. Webpack 5 is not supported yet but maintainers are planning to add support. So you can change several lines in default.config.js output section from:

output: {
// The build folder.
path: isEnvProduction ? paths.appBuild : undefined,
// blah blah blah
}
to:

output: {
// The build folder.
path: paths.appBuild,
// blah blah blah
}

Source: https://stackoverflow.com/questions/64019154/migrating-cra-to-webpack-5

@raix
Copy link
Contributor Author

raix commented Mar 20, 2021

@rickihastings now using asset modules
@kumarlachhani thanks, the config is simplified
@vjpr nope not going to take on the task of releasing npm packages, I don't have the time for it - I did talk with @andriijas about creating a WP5 feature branch - maybe do prereleases from that branch (eg. a cra v5 branch as removing nodejs builtin shims could be a breaking change although necessary)

Note: I did change alot of things, but have not tested extensively - a prerelease would enable the community to help out testing to harden this thing.

Thank you for the feedback! :)

@@ -5,6 +5,9 @@
/.pnp
.pnp.js

# build cache info
tsconfig.tsbuildinfo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should set compilerOptions tsBuildInfoFile: paths.cacheTsBuildInfoFile in the ForkTsCheckerWebpackPlugin

@Chastrlove
Copy link

@raix

I try to change the code in App.js
import {ReactComponent as Logo} from './logo.svg';

Then the error shows:
Can't import the named export 'ReactComponent' (imported as 'Logo') from default-exporting module (only default export is available)

@lukaskoeller
Copy link

Is there anything I can support with? I do like the initiative on updating webpack to v5 and would like to support if possible/needed

@raix
Copy link
Contributor Author

raix commented Mar 29, 2021

@lukaskoeller Currently svgr react component imports seems broken + when starting in watch mode it seems a bit clucky/extra refresh + general QA/test pnp etc. I'll try to get a feature branch up this week making it easier to test/contribute

@popuguytheparrot
Copy link

How can i help with this PR?

@@ -137,28 +134,16 @@ function createCompiler({

let isFirstCompile = true;
let tsMessagesPromise;

Choose a reason for hiding this comment

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

tsMessagesPromise doesn't get resolved anywhere, does it?

@Bluefitdev
Copy link

I want to help too if you have too if you need any :). Hopefully this is released soon

Morten N.O. Henriksen added 3 commits May 14, 2021 18:13
* upstream/wp5:
  Remove outdated comments on react-refresh (#10784)
  Suggest sass instead of node-sass package (#10779)
  Upgrade docs http links to https (#10288)
  Fix ICSS syntax in stylesheets (#10511)
  Update PWA docs to point at the cra-template-pwa package (#10805)
  Trivial English fixes (#10763)
  Bump y18n from 4.0.0 to 4.0.1 in /docusaurus/website (#10765)
  Update ModuleNotFoundPlugin to support Webpack 5 (#10205)
  Update WebpackManifestPlugin (#10204)
  Update PostCSS packages (#10456)
  react-dev-utils@11.0.4
  Security Fix for Command Injection - huntr.dev (#10644)
@raix raix mentioned this pull request May 14, 2021
@raix
Copy link
Contributor Author

raix commented May 14, 2021

Closing this pull-request in favor of #10961 targeted the wp5 branch

@raix raix closed this May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.