Skip to content

Commit

Permalink
Optimize watch ignore (#52238)
Browse files Browse the repository at this point in the history
## What?

Uses a pre-created regex instead of having webpack run path-to-regexp on the list of patterns. Saves a few milliseconds.
Adds `node_modules` to ignored in order to skip a lot of stat calls at the end of the compilation.

This will likely have a big impact on applications using Yarn PnP as each stat call causes a lookup through `.pnp.cjs`.
  • Loading branch information
timneutkens authored and shuding committed Jul 8, 2023
1 parent b91b8ea commit b5dea00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ const nodePathList = (process.env.NODE_PATH || '')

const watchOptions = Object.freeze({
aggregateTimeout: 5,
ignored: ['**/.git/**', '**/.next/**'],
ignored:
// Matches **/node_modules/**, **/.git/** and **/.next/**
/^((?:[^/]*(?:\/|$))*)(\.(git|next)|node_modules)(\/((?:[^/]*(?:\/|$))*)(?:$|\/))?/,
})

function isModuleCSS(module: { type: string }) {
Expand Down

0 comments on commit b5dea00

Please sign in to comment.