Skip to content

Commit

Permalink
Use normalizePathSep helper
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Jan 2, 2024
1 parent 0dcd4d6 commit 083551e
Showing 1 changed file with 5 additions and 2 deletions.
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 @@ -223,7 +224,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').replace(/\\/g, '/')}`
return `commonjs ${normalizePathSep(
localRes.replace(/.*?next[/\\]dist/, 'next/dist')
)}`
}
}

Expand Down Expand Up @@ -276,7 +279,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

0 comments on commit 083551e

Please sign in to comment.