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 path issues on linux machines when build created on windows #60116

Merged
merged 5 commits into from
Jan 2, 2024
Merged
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
7 changes: 5 additions & 2 deletions packages/next/src/build/handle-externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from './webpack-config'
import { isWebpackAppLayer, isWebpackServerLayer } from './worker'
import type { NextConfigComplete } from '../server/config-shared'
import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'
const reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\/)/

const pathSeparators = '[/\\\\]'
Expand Down Expand Up @@ -234,7 +235,9 @@ export function makeExternalHandler({
if (isExternal) {
// it's important we return the path that starts with `next/dist/` here instead of the absolute path
// otherwise NFT will get tripped up
return `commonjs ${localRes.replace(/.*?next[/\\]dist/, 'next/dist')}`
return `commonjs ${normalizePathSep(
localRes.replace(/.*?next[/\\]dist/, 'next/dist')
huozhi marked this conversation as resolved.
Show resolved Hide resolved
)}`
}
}

Expand Down Expand Up @@ -288,7 +291,7 @@ export function makeExternalHandler({
if (layer === WEBPACK_LAYERS.serverSideRendering) {
const isRelative = request.startsWith('.')
const fullRequest = isRelative
? path.join(context, request).replace(/\\/g, '/')
? normalizePathSep(path.join(context, request))
: request
return resolveNextExternal(fullRequest)
}
Expand Down