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

Webpack 4, react-error-overlay, react-loadable (major) #4639

Merged
merged 122 commits into from
Jul 24, 2018

Conversation

timneutkens
Copy link
Member

@timneutkens timneutkens commented Jun 20, 2018

Fixes #4783
Fixes #2643
Fixes #3775
Fixes #4515
Fixes #3923
Fixes #4433
Fixes #4100
Fixes #4642
Fixes #3823
Fixes #4708
Fixes #4285
Fixes #4194
Fixes #4784
Fixes #4737
Fixes #4711
Fixes #3165
Fixes #2480
Fixes #1428
Fixes #2894
Fixes #4629
Fixes #2940
Fixes #4175
Fixes vercel/next-plugins#122
Implements a few fixes for #4613

Figured out the chunk runtime merging issue described in #4108

New pull request as the codebase since the initial pull request has shifted quite a bit (folders moved etc).

What's left to do:

  • Failing tests (not all of these are failing, keeping a list of tests I checked and fixed already (or weren't broken))
    • basic
    • static
    • app-aspath
    • app-document
    • babel
    • config
    • dist-dir
    • custom-server
    • ondemand
    • production
    • with-router
  • Correct split chunk configuration
    • commons.js for modules used in 50% of all pages
    • hashing of main.js and runtime.js
  • Upgrade uses of old webpack plugin hooks system
  • Replace custom error overlay with react-error-overlay, which improves DX + gives more accurate error locations.
    • Make react-error-overlay work with errors coming from SSR
    • Reload the page whenever an error is fixed
  • next/dynamic replaced by react-loadable under the hood. No changes in how it currently works. Only 1 specific edge case has a breaking change, see breaking below

Changes

Major

  • Node.js 8+ is now required.
  • Webpack 4, all plugins rewritten to use the Webpack 4 API
  • Re-implemented next/dynamic using react-loadable under the hood, this means that you still use next/dynamic but underneath it will use react-loadable instead of the previous custom solution.
  • Implemented react-error-overlay / new hot-dev-client implementation (overhauled error rendering in development)
  • Share module instances initiated by webpack between pages on the server side, allows for React 16.3 context between _app.js and pages and basically any other requirement for sharing module instances on the server side. I can also imagine this greatly reduces memory usage / improves speed in a serverless environment too.

Minor

  • Removed 2 "webpack specific" routes. These files are now put into .next/static: .next/static/webpack (hot update files) and .next/static/chunks (dynamic import files)
  • Added Webpackbar

Patches

Breaking

After the canary release

  • config tests failing on @zeit/next-css because of webpack 4, temporarily disabled.
  • Update next-plugins
  • Add modules imported in _app.js to commons as _app.js is loaded in every page. Question on webpack/webpack for advice

@stramel
Copy link
Contributor

stramel commented Jun 28, 2018

@timneutkens What are your Node.js supported versions? LTS is now 8. Curious if we need the 6 & 7 checks?

BTW great work! Can't wait to try out webpack 4!

@timneutkens
Copy link
Member Author

All tests run on Node.js 6, but it's recommended to use the latest LTS/later version of Node.js

@stramel
Copy link
Contributor

stramel commented Jul 1, 2018

@timneutkens not sure if you saw this about the minimizer https://twitter.com/greweb/status/1013122437884542978

@stramel
Copy link
Contributor

stramel commented Jul 2, 2018

@timneutkens I believe this will also fix #4100 and #4642 ?

@timneutkens
Copy link
Member Author

@stramel 😌 thanks!

Will check the minimizer out once all tests pass 👍

Copy link
Contributor

@arunoda arunoda left a comment

Choose a reason for hiding this comment

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

LGTM

@timneutkens timneutkens changed the title [WIP] Webpack 4, react-error-overlay, react-loadable Webpack 4, react-error-overlay, react-loadable (major) Jul 24, 2018
@timneutkens timneutkens merged commit 75476a9 into vercel:canary Jul 24, 2018
@timneutkens timneutkens deleted the webpack branch July 24, 2018 09:24
@u840903
Copy link

u840903 commented Jul 24, 2018

Oh lordy!
Great work Tim!

@albinekb
Copy link
Contributor

Freaking awesome work! 😍

@morgs32
Copy link

morgs32 commented Jul 24, 2018

Congratulations! Small step for man...

@tomevans18
Copy link

tomevans18 commented Jul 25, 2018

Great work on this, lots of fixes.
Are you looking to release this as "6.1.1-canary.3"?
Just a little desperate for the dynamic imports.

@pantharshit00
Copy link

Ya need this ASAP cause SSR is breaking on my app if I am trying to use context

@mariosanchez
Copy link

Good job! Very happy to have Webpack 4 arround the corner 👍

@jesstelford
Copy link
Contributor

It looks like Webpack 4 is included in 6.1.1-canary.3 🎉

timneutkens pushed a commit that referenced this pull request Sep 23, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.