Skip to content

Commit 8e9f082

Browse files
committed
fix: normalize paths
1 parent b271c6e commit 8e9f082

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/helpers/config.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
const { readJSON } = require('fs-extra')
3-
const { join, dirname, relative } = require('pathe')
3+
const { join, dirname, relative, normalize } = require('pathe')
44

55
const defaultFailBuild = (message, { error }) => {
66
throw new Error(`${message}\n${error && error.stack}`)
@@ -111,7 +111,15 @@ exports.getNextConfig = async function getNextConfig({ publish, failBuild = defa
111111

112112
const resolveModuleRoot = (moduleName) => {
113113
try {
114-
return dirname(relative(process.cwd(), require.resolve(`${moduleName}/package.json`, { paths: [process.cwd()] })))
114+
const modulePkg = require.resolve(`${moduleName}/package.json`, { paths: [process.cwd()] })
115+
console.log('resolving', moduleName, normalize(process.cwd()), modulePkg, normalize(modulePkg))
116+
117+
return dirname(
118+
relative(
119+
normalize(process.cwd()),
120+
normalize(require.resolve(`${moduleName}/package.json`, { paths: [process.cwd()] })),
121+
),
122+
)
115123
} catch (error) {
116124
return null
117125
}
@@ -137,7 +145,6 @@ exports.configureHandlerFunctions = ({ netlifyConfig, publish, ignore = [] }) =>
137145
const nextRoot = resolveModuleRoot('next')
138146
if (nextRoot) {
139147
netlifyConfig.functions[functionName].included_files.push(
140-
`!${nextRoot}/dist/pages/**/*`,
141148
`!${nextRoot}/dist/server/lib/squoosh/**/*.wasm`,
142149
`!${nextRoot}/dist/next-server/server/lib/squoosh/**/*.wasm`,
143150
`!${nextRoot}/dist/compiled/webpack/bundle4.js`,

test/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,11 @@ describe('onBuild()', () => {
195195
'.next/*.json',
196196
'.next/BUILD_ID',
197197
'!../node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*',
198-
'!node_modules/next/dist/pages/**/*',
199198
`!node_modules/next/dist/server/lib/squoosh/**/*.wasm`,
200199
`!node_modules/next/dist/next-server/server/lib/squoosh/**/*.wasm`,
201200
'!node_modules/next/dist/compiled/webpack/bundle4.js',
202201
'!node_modules/next/dist/compiled/webpack/bundle5.js',
203202
'!node_modules/next/dist/compiled/terser/bundle.min.js',
204-
'!node_modules/react/**/*.development.js',
205-
'!node_modules/react-dom/**/*.development.js',
206203
'!node_modules/sharp/**/*',
207204
]
208205
expect(netlifyConfig.functions[HANDLER_FUNCTION_NAME].included_files).toEqual(includes)

0 commit comments

Comments
 (0)