Skip to content

Commit

Permalink
fix problem with HMR when middleware and page reference the same node…
Browse files Browse the repository at this point in the history
…_module
  • Loading branch information
sokra committed Feb 1, 2022
1 parent 791c356 commit d72c9b9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
7 changes: 0 additions & 7 deletions packages/next/build/webpack-config.ts
Expand Up @@ -1256,13 +1256,6 @@ export default async function getBaseWebpackConfig(
},
],
},
{
...nonUserCondition,
// Make all non-user modules to be compiled in a single layer
// This avoids compiling them mutliple times and avoids module id changes
issuerLayer: 'middleware',
layer: '',
},
...(!config.images.disableStaticImages
? [
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/integration/middleware/hmr/pages/about/_middleware.js
@@ -1,5 +1,7 @@
import { NextResponse } from 'next/server'
import magicValue from 'shared-package'

export function middleware(request) {
if (magicValue !== 42) throw new Error('shared-package problem')
return NextResponse.rewrite(new URL('/about/a', request.url))
}
3 changes: 3 additions & 0 deletions test/integration/middleware/hmr/pages/index.js
@@ -1,3 +1,6 @@
import magicValue from 'shared-package'
if (magicValue !== 42) throw new Error('shared-package problem')

export default function Home() {
return (
<div>
Expand Down

0 comments on commit d72c9b9

Please sign in to comment.