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

Remove webpack 4 support #26915

Closed
wants to merge 53 commits into from

Conversation

timneutkens
Copy link
Member

@timneutkens timneutkens commented Jul 4, 2021

PR for the next major version to remove webpack 4 support.

Notable changes:

  • This simplifies config loading as we no longer have to load the config in webpack 4 mode first which will speed up bootup significantly.
  • Removed all cases of isWebpack5 as there's no difference between versions
  • Removed the legacy webpack ConformancePlugin experiment (this is not conformance as introduced in Next.js 11)
    • This allowed for removing ast-types and recast deps
  • Removed chokidar dep as it was only needed by webpack 4
  • Removed next-babel-loader which was the legacy babel loader that was superseded by the new optimized Babel loader introduced in Next.js 11. This loader was used only when using webpack 4.
    • Allowed for removing cacache dependency
  • Removed emit-file-loader, we've kept this loader around for quite some time even though it's not used in Next.js
  • Updated a few test regexes that did not escape .
  • Removed chunk-names-plugin as webpack 5 support correctly naming files
  • Removed ssr-module-cache-plugin as webpack 5 correctly caches module instances between files
  • Removed isWebpack5 in tests
  • Updates cases where tests suddenly started failing because of eslint support
  • Removed .eslintignore for test/integration/async-modules
  • Added support for top level await to Next.js eslint preset
  • Added support for ignoring all files in .eslintignore (previously caused an unhelpful error)

TODO:

  • Remove custom webpack.d.ts to leverage built-in webpack 5 types. (not needed to land this PR)

Closes #26448

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes

@ijjk ijjk added created-by: Next.js team PRs by the Next.js team. type: next labels Jul 4, 2021
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@timneutkens timneutkens changed the title WIP Remove webpack 4 support Remove webpack 4 support Jul 6, 2021
@timneutkens timneutkens marked this pull request as ready for review July 6, 2021 15:30
@timneutkens timneutkens marked this pull request as draft July 6, 2021 15:45
@ijjk
Copy link
Member

ijjk commented Jul 6, 2021

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
buildDuration 14.6s 14.3s -223ms
buildDurationCached 3.5s 3.1s -371ms
nodeModulesSize 49.3 MB 43.7 MB -5.58 MB
Page Load Tests Overall increase ✓
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
/ failed reqs 0 0
/ total time (seconds) 2.634 2.7 ⚠️ +0.07
/ avg req/sec 949.08 926.08 ⚠️ -23
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.681 1.64 -0.04
/error-in-render avg req/sec 1487.47 1523.95 +36.48
Client Bundles (main, webpack, commons)
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
359.HASH.js gzip 3.09 kB 3.09 kB
framework-HASH.js gzip 42 kB 42 kB
main-HASH.js gzip 20.6 kB 20.6 kB
webpack-HASH.js gzip 1.49 kB 1.49 kB
Overall change 67.2 kB 67.2 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
_app-HASH.js gzip 803 B 803 B
_error-HASH.js gzip 3.18 kB 3.18 kB
amp-HASH.js gzip 526 B 526 B
css-HASH.js gzip 329 B 329 B
hooks-HASH.js gzip 903 B 903 B
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 1.65 kB 1.65 kB
routerDirect..HASH.js gzip 322 B 322 B
withRouter-HASH.js gzip 320 B 320 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 8.42 kB 8.42 kB
Client Build Manifests
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
_buildManifest.js gzip 390 B 390 B
Overall change 390 B 390 B
Rendered Page Sizes
vercel/next.js canary timneutkens/next.js add/remove-webpack4 Change
index.html gzip 523 B 523 B
link.html gzip 537 B 537 B
withRouter.html gzip 515 B 515 B
Overall change 1.57 kB 1.57 kB
Commit: 6077f10

// If the user decides to `.eslintignore` all of the files in the lint directory it should not throw an error during `next build` or `next lint`
if (err?.messageTemplate === 'all-files-ignored') {
return null
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be removed in place of disabling the errorOnUnmatchedPattern property (done here: #27119)

timneutkens added a commit to timneutkens/next.js that referenced this pull request Jul 30, 2021
This was superseded by the conformance system published in Next.js 11.

Follow-up to vercel#26448
Separated out change from vercel#26915
@timneutkens timneutkens mentioned this pull request Oct 6, 2021
10 tasks
@timneutkens
Copy link
Member Author

This has landed in #29660

@chirag04
Copy link

@timneutkens can we land 134a363 which is a blocker for webpack5 upgrade for those using serverless?

@timneutkens
Copy link
Member Author

That's already landed @chirag04 🤔

@chirag04
Copy link

chirag04 commented Oct 25, 2021

@timneutkens maybe i'm looking at it in the wrong place but i don't see the change in master: https://github.com/vercel/next.js/blob/master/packages/next/build/webpack/plugins/serverless-plugin.ts#L26-L36

I will try upgrading to webpack 5 to see if we still need this.

@timneutkens
Copy link
Member Author

The master branch is never used, we only work on the canary branch.

@chirag04
Copy link

ah! apologies. I didn't realize. will try to upgrade and see how it goes. Thanks for the help @timneutkens .

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants