Skip to content

Commit 53020f5

Browse files
committed
fix: :old-man-yells-at-windows-paths:
1 parent f342a22 commit 53020f5

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/runtime/src/templates/getPageResolver.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { posix } from 'path'
2-
31
import glob from 'globby'
42
import { outdent } from 'outdent'
5-
import { relative, resolve } from 'pathe'
6-
import slash from 'slash'
3+
import { join, relative, resolve } from 'pathe'
74

85
import { HANDLER_FUNCTION_NAME } from '../constants'
96
import { getDependenciesOfFile } from '../helpers/files'
@@ -17,15 +14,15 @@ export const getUniqueDependencies = async (sourceFiles: Array<string>) => {
1714
}
1815

1916
export const getAllPageDependencies = async (publish: string) => {
20-
const root = posix.resolve(slash(publish), 'server')
17+
const root = resolve(publish, 'server')
2118

2219
const pageFiles = await glob('{pages,app}/**/*.js', {
2320
cwd: root,
24-
absolute: true,
2521
dot: true,
2622
})
27-
28-
return getUniqueDependencies(pageFiles)
23+
// We don't use `absolute: true` because that returns Windows paths on Windows.
24+
// Instead we use pathe to normalize the paths.
25+
return getUniqueDependencies(pageFiles.map((pageFile) => join(root, pageFile)))
2926
}
3027

3128
export const getResolverForDependencies = ({
@@ -47,7 +44,7 @@ export const getResolverForDependencies = ({
4744
}
4845

4946
export const getResolverForPages = async (publish: string) => {
50-
const functionDir = posix.resolve(posix.join('.netlify', 'functions', HANDLER_FUNCTION_NAME))
47+
const functionDir = resolve('.netlify', 'functions', HANDLER_FUNCTION_NAME)
5148
const dependencies = await getAllPageDependencies(publish)
5249
return getResolverForDependencies({ dependencies, functionDir })
5350
}

0 commit comments

Comments
 (0)