Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
restore webpack defaults for managed/immutablePaths (vercel#25250)
Browse files Browse the repository at this point in the history
Due to bundling of webpack the default values can't be correctly detected
This restores the webpack defaults
  • Loading branch information
sokra committed May 19, 2021
1 parent 31317a6 commit e33fd55
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,47 @@ export default async function getBaseWebpackConfig(
// webpack 5 no longer polyfills Node.js modules:
if (webpackConfig.node) delete webpackConfig.node.setImmediate

// Due to bundling of webpack the default values can't be correctly detected
// This restores the webpack defaults
// @ts-ignore webpack 5
webpackConfig.snapshot = {}
if (process.versions.pnp === '3') {
const match = /^(.+?)[\\/]cache[\\/]jest-worker-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
require.resolve('jest-worker')
)
if (match) {
// @ts-ignore webpack 5
webpackConfig.snapshot.managedPaths = [
path.resolve(match[1], 'unplugged'),
]
}
} else {
const match = /^(.+?[\\/]node_modules)[\\/]/.exec(
require.resolve('jest-worker')
)
if (match) {
// @ts-ignore webpack 5
webpackConfig.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) {
// @ts-ignore webpack 5
webpackConfig.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) {
// @ts-ignore webpack 5
webpackConfig.snapshot.immutablePaths = [match[1]]
}
}

if (dev) {
if (!webpackConfig.optimization) {
webpackConfig.optimization = {}
Expand Down

0 comments on commit e33fd55

Please sign in to comment.