Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure webpack cache is invalidated for alias change #24956

Merged
merged 3 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ export default async function getBaseWebpackConfig(
target,
reactProductionProfiling,
webpack: !!config.webpack,
hasRewrites,
})

const cache: any = {
Expand Down
1 change: 1 addition & 0 deletions test/integration/custom-routes/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
// target: 'serverless',
async rewrites() {
// no-rewrites comment
return {
afterFiles: [
...(process.env.ADD_NOOP_REWRITE === 'true'
Expand Down
23 changes: 22 additions & 1 deletion test/integration/custom-routes/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1731,12 +1731,33 @@ describe('Custom routes', () => {
})

describe('dev mode', () => {
let nextConfigContent

beforeAll(async () => {
// ensure cache with rewrites disabled doesn't persist
// after enabling rewrites
await fs.remove(join(appDir, '.next'))
nextConfigContent = await fs.readFile(nextConfigPath, 'utf8')
await fs.writeFile(
nextConfigPath,
nextConfigContent.replace('// no-rewrites comment', 'return []')
)

const tempPort = await findPort()
const tempApp = await launchApp(appDir, tempPort)
await renderViaHTTP(tempPort, '/')

await killApp(tempApp)
await fs.writeFile(nextConfigPath, nextConfigContent)

appPort = await findPort()
app = await launchApp(appDir, appPort)
buildId = 'development'
})
afterAll(() => killApp(app))
afterAll(async () => {
await fs.writeFile(nextConfigPath, nextConfigContent)
await killApp(app)
})
runTests(true)
})

Expand Down