Unverified Commit ecf2ee9c authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

automatically enable managed paths for all node_modules (#30089)

This improves caching performance in monorepos where there are multiple node_modules folders
Automatically enable immutable paths for Yarn PnP
parent dd81d2c9
...@@ -1349,43 +1349,21 @@ export default async function getBaseWebpackConfig( ...@@ -1349,43 +1349,21 @@ export default async function getBaseWebpackConfig(
!/[\\/]pages[\\/][^\\/]+(?:$|\?|#)/.test(module.resource) !/[\\/]pages[\\/][^\\/]+(?:$|\?|#)/.test(module.resource)
} }
// Due to bundling of webpack the default values can't be correctly detected // This enables managedPaths for all node_modules
// This restores the webpack defaults // and also for the unplugged folder when using yarn pnp
// It also add the yarn cache to the immutable paths
webpack5Config.snapshot = {} webpack5Config.snapshot = {}
if (process.versions.pnp === '3') { if (process.versions.pnp === '3') {
const match =
/^(.+?)[\\/]cache[\\/]jest-worker-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
require.resolve('jest-worker')
)
if (match) {
webpack5Config.snapshot.managedPaths = [ webpack5Config.snapshot.managedPaths = [
path.resolve(match[1], 'unplugged'), /^(.+?(?:[\\/]\.yarn[\\/]unplugged[\\/][^\\/]+)?[\\/]node_modules[\\/])/,
] ]
}
} else { } else {
const match = /^(.+?[\\/]node_modules)[\\/]/.exec( webpack5Config.snapshot.managedPaths = [/^(.+?[\\/]node_modules[\\/])/]
require.resolve('jest-worker')
)
if (match) {
webpack5Config.snapshot.managedPaths = [match[1]]
}
}
if (process.versions.pnp === '1') {
const match =
/^(.+?[\\/]v4)[\\/]npm-jest-worker-[^\\/]+-[\da-f]{40}[\\/]node_modules[\\/]/.exec(
require.resolve('jest-worker')
)
if (match) {
webpack5Config.snapshot.immutablePaths = [match[1]]
}
} else if (process.versions.pnp === '3') {
const match =
/^(.+?)[\\/]jest-worker-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
require.resolve('jest-worker')
)
if (match) {
webpack5Config.snapshot.immutablePaths = [match[1]]
} }
if (process.versions.pnp === '3') {
webpack5Config.snapshot.immutablePaths = [
/^(.+?[\\/]cache[\\/][^\\/]+\.zip[\\/]node_modules[\\/])/,
]
} }
if (dev) { if (dev) {
......
...@@ -38,7 +38,7 @@ module.exports = JSON.parse("{\"application/1d-interleaved-parityfec\":{\"source ...@@ -38,7 +38,7 @@ module.exports = JSON.parse("{\"application/1d-interleaved-parityfec\":{\"source
/***/ (function(module) { /***/ (function(module) {
"use strict"; "use strict";
module.exports = {"i8":"5.59.0"}; module.exports = {"i8":"5.59.1"};
/***/ }), /***/ }),
...@@ -42883,7 +42883,7 @@ class FileSystemInfo { ...@@ -42883,7 +42883,7 @@ class FileSystemInfo {
for (const managedPath of this.managedPathsRegExps) { for (const managedPath of this.managedPathsRegExps) {
const match = managedPath.exec(path); const match = managedPath.exec(path);
if (match) { if (match) {
const managedItem = getManagedItem(managedPath[1], path); const managedItem = getManagedItem(match[1], path);
if (managedItem) { if (managedItem) {
managedItems.add(managedItem); managedItems.add(managedItem);
managedSet.add(path); managedSet.add(path);
...@@ -43857,7 +43857,7 @@ class FileSystemInfo { ...@@ -43857,7 +43857,7 @@ class FileSystemInfo {
for (const managedPath of this.managedPathsRegExps) { for (const managedPath of this.managedPathsRegExps) {
const match = managedPath.exec(path); const match = managedPath.exec(path);
if (match) { if (match) {
const managedItem = getManagedItem(managedPath[1], path); const managedItem = getManagedItem(match[1], path);
if (managedItem) { if (managedItem) {
// construct timestampHash from managed info // construct timestampHash from managed info
return this.managedItemQueue.add(managedItem, (err, info) => { return this.managedItemQueue.add(managedItem, (err, info) => {
...@@ -110990,6 +110990,7 @@ Run build with un-frozen lockfile to automatically fix lockfile.` ...@@ -110990,6 +110990,7 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
inProgressWrite.push(runWrite); inProgressWrite.push(runWrite);
} else { } else {
inProgressWrite = []; inProgressWrite = [];
runWrite();
} }
} }
); );
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
"webpack-sources1": "npm:webpack-sources@1.4.3", "webpack-sources1": "npm:webpack-sources@1.4.3",
"webpack-sources3": "npm:webpack-sources@3.2.0", "webpack-sources3": "npm:webpack-sources@3.2.0",
"webpack4": "npm:webpack@4.44.1", "webpack4": "npm:webpack@4.44.1",
"webpack5": "npm:webpack@5.59.0", "webpack5": "npm:webpack@5.59.1",
"ws": "8.2.3" "ws": "8.2.3"
}, },
"resolutions": { "resolutions": {
......
...@@ -19828,10 +19828,10 @@ webpack-sources@^3.2.0: ...@@ -19828,10 +19828,10 @@ webpack-sources@^3.2.0:
watchpack "^1.7.4" watchpack "^1.7.4"
webpack-sources "^1.4.1" webpack-sources "^1.4.1"
"webpack5@npm:webpack@5.59.0": "webpack5@npm:webpack@5.59.1":
version "5.59.0" version "5.59.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.59.0.tgz#a5038fc0d4d9350ee528e7e1e0282080c63efcf5" resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.59.1.tgz#60c77e9aad796252153d4d7ab6b2d4c11f0e548c"
integrity sha512-2HiFHKnWIb/cBfOfgssQn8XIRvntISXiz//F1q1+hKMs+uzC1zlVCJZEP7XqI1wzrDyc/ZdB4G+MYtz5biJxCA== integrity sha512-I01IQV9K96FlpXX3V0L4nvd7gb0r7thfuu1IfT2P4uOHOA77nKARAKDYGe/tScSHKnffNIyQhLC8kRXzY4KEHQ==
dependencies: dependencies:
"@types/eslint-scope" "^3.7.0" "@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.50" "@types/estree" "^0.0.50"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment