@@ -2,13 +2,16 @@ import { existsSync } from 'node:fs'
2
2
import { cp , mkdir , readFile , readdir , readlink , symlink , writeFile } from 'node:fs/promises'
3
3
import { createRequire } from 'node:module'
4
4
// eslint-disable-next-line no-restricted-imports
5
- import { dirname , join , resolve } from 'node:path'
5
+ import { dirname , join , resolve , sep } from 'node:path'
6
+ import { sep as posixSep } from 'node:path/posix'
6
7
7
8
import glob from 'fast-glob'
8
9
9
10
import { RUN_CONFIG } from '../../run/constants.js'
10
11
import { PluginContext } from '../plugin-context.js'
11
12
13
+ const toPosixPath = ( path : string ) => path . split ( sep ) . join ( posixSep )
14
+
12
15
/**
13
16
* Copy App/Pages Router Javascript needed by the server handler
14
17
*/
@@ -26,7 +29,7 @@ export const copyNextServerCode = async (ctx: PluginContext): Promise<void> => {
26
29
// this means the path got altered by a plugin like nx and contained ../../ parts so we have to reset it
27
30
// to point to the correct lambda destination
28
31
if (
29
- ctx . distDir . replace ( new RegExp ( `^${ ctx . packagePath } /?` ) , '' ) !== reqServerFiles . config . distDir
32
+ toPosixPath ( ctx . distDir ) . replace ( new RegExp ( `^${ ctx . packagePath } /?` ) , '' ) !== reqServerFiles . config . distDir
30
33
) {
31
34
// set the distDir to the latest path portion of the publish dir
32
35
reqServerFiles . config . distDir = ctx . nextDistDir
@@ -45,7 +48,7 @@ export const copyNextServerCode = async (ctx: PluginContext): Promise<void> => {
45
48
46
49
const srcDir = join ( ctx . standaloneDir , ctx . nextDistDir )
47
50
// if the distDir got resolved and altered use the nextDistDir instead
48
- const nextFolder = ctx . distDir === ctx . buildConfig . distDir ? ctx . distDir : ctx . nextDistDir
51
+ const nextFolder = toPosixPath ( ctx . distDir ) === toPosixPath ( ctx . buildConfig . distDir ) ? ctx . distDir : ctx . nextDistDir
49
52
const destDir = join ( ctx . serverHandlerDir , nextFolder )
50
53
51
54
const paths = await glob (
0 commit comments