Unverified Commit c2c1b965 authored by Felipe Lima's avatar Felipe Lima Committed by GitHub

Fix webpack5 cache distDir (#23718)



## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

## 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.

## Documentation / Examples

- [ ] Make sure the linting passes

Fixes: #23716
parent 9986d7c9
...@@ -966,7 +966,7 @@ export default async function getBaseWebpackConfig( ...@@ -966,7 +966,7 @@ export default async function getBaseWebpackConfig(
loader: 'next/dist/compiled/cache-loader', loader: 'next/dist/compiled/cache-loader',
options: { options: {
cacheContext: dir, cacheContext: dir,
cacheDirectory: path.join(dir, '.next', 'cache', 'webpack'), cacheDirectory: path.join(distDir, 'cache', 'webpack'),
cacheIdentifier: `webpack${isServer ? '-server' : ''}`, cacheIdentifier: `webpack${isServer ? '-server' : ''}`,
}, },
}, },
...@@ -1271,7 +1271,7 @@ export default async function getBaseWebpackConfig( ...@@ -1271,7 +1271,7 @@ export default async function getBaseWebpackConfig(
// - Next.js version // - Next.js version
// - next.config.js keys that affect compilation // - next.config.js keys that affect compilation
version: `${process.env.__NEXT_VERSION}|${configVars}`, version: `${process.env.__NEXT_VERSION}|${configVars}`,
cacheDirectory: path.join(dir, '.next', 'cache', 'webpack'), cacheDirectory: path.join(distDir, 'cache', 'webpack'),
} }
// Adds `next.config.js` as a buildDependency when custom webpack config is provided // Adds `next.config.js` as a buildDependency when custom webpack config is provided
......
...@@ -39,9 +39,7 @@ describe('distDir', () => { ...@@ -39,9 +39,7 @@ describe('distDir', () => {
).toBeTruthy() ).toBeTruthy()
}) })
it('should not build the app within the default `.next` directory', async () => { it('should not build the app within the default `.next` directory', async () => {
expect( expect(await fs.exists(join(__dirname, '/../.next'))).toBeFalsy()
await fs.exists(join(__dirname, `/../.next/${BUILD_ID_FILE}`))
).toBeFalsy()
}) })
}) })
......
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