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

fix problem with HMR when middleware and page reference the same node_module #33873

Merged
merged 2 commits into from Feb 1, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 0 additions & 12 deletions packages/next/build/webpack-config.ts
Expand Up @@ -959,11 +959,6 @@ export default async function getBaseWebpackConfig(
},
}

const nonUserCondition = {
include: /node_modules/,
exclude: babelIncludeRegexes,
}

let webpackConfig: webpack.Configuration = {
parallelism: Number(process.env.NEXT_WEBPACK_PARALLELISM) || undefined,
externals: targetWeb
Expand Down Expand Up @@ -1256,13 +1251,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