Skip to content

Commit

Permalink
Add isDevfallback to cache name to create a separate cache for the fa…
Browse files Browse the repository at this point in the history
…llback compiler (#30227)
  • Loading branch information
timneutkens committed Oct 24, 2021
1 parent 5d8f155 commit 417ad95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export default async function getBaseWebpackConfig(
options: {
isServer,
pagesDir,
hasReactRefresh,
},
}
: {
Expand Down Expand Up @@ -1513,6 +1514,11 @@ export default async function getBaseWebpackConfig(
isCraCompat: config.experimental.craCompat,
})

// @ts-ignore Cache exists
webpackConfig.cache.name = `${webpackConfig.name}-${webpackConfig.mode}${
isDevFallback ? '-fallback' : ''
}`

let originalDevtool = webpackConfig.devtool
if (typeof config.webpack === 'function') {
webpackConfig = config.webpack(webpackConfig, {
Expand Down
6 changes: 4 additions & 2 deletions packages/next/build/webpack/loaders/next-swc-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function getSWCOptions({
isPageFile,
pagesDir,
isNextDist,
hasReactRefresh,
isCommonJS,
}) {
const jsc = {
Expand All @@ -56,7 +57,7 @@ function getSWCOptions({
throwIfNamespace: true,
development: development,
useBuiltins: true,
refresh: development && !isServer,
refresh: hasReactRefresh,
},
optimizer: {
simplify: false,
Expand Down Expand Up @@ -122,7 +123,7 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {

let loaderOptions = getOptions(this) || {}

const { isServer, pagesDir } = loaderOptions
const { isServer, pagesDir, hasReactRefresh } = loaderOptions
const isPageFile = filename.startsWith(pagesDir)

const isNextDist = nextDistPath.test(filename)
Expand All @@ -136,6 +137,7 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
development: this.mode === 'development',
isNextDist,
isCommonJS,
hasReactRefresh,
})

const programmaticOptions = {
Expand Down

0 comments on commit 417ad95

Please sign in to comment.