@netlify/plugin-nextjs 4.28.4 → 4.28.5-resolve-app.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/helpers/functions.js
CHANGED
|
@@ -35,9 +35,11 @@ const generateFunctions = async ({ FUNCTIONS_SRC = constants_1.DEFAULT_FUNCTIONS
|
|
|
35
35
|
await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsDir, functionName, `${functionName}.js`), apiHandlerSource);
|
|
36
36
|
await (0, fs_extra_1.copyFile)(node_bridge_1.default, (0, pathe_1.join)(functionsDir, functionName, 'bridge.js'));
|
|
37
37
|
await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'handlerUtils.js'), (0, pathe_1.join)(functionsDir, functionName, 'handlerUtils.js'));
|
|
38
|
+
const resolveSourceFile = (file) => (0, pathe_1.join)(publish, 'server', file);
|
|
38
39
|
const resolverSource = await (0, getPageResolver_1.getSinglePageResolver)({
|
|
39
40
|
functionsDir,
|
|
40
|
-
|
|
41
|
+
// These extra pages are always included by Next.js
|
|
42
|
+
sourceFiles: [compiled, 'pages/_app.js', 'pages/_document.js', 'pages/_error.js'].map(resolveSourceFile),
|
|
41
43
|
});
|
|
42
44
|
await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsDir, functionName, 'pages.js'), resolverSource);
|
|
43
45
|
}
|
|
@@ -37,11 +37,12 @@ exports.getPageResolver = getPageResolver;
|
|
|
37
37
|
* API routes only need the dependencies for a single entrypoint, so we use the
|
|
38
38
|
* NFT trace file to get the dependencies.
|
|
39
39
|
*/
|
|
40
|
-
const getSinglePageResolver = async ({ functionsDir,
|
|
41
|
-
const dependencies = await (0, files_1.getDependenciesOfFile)(sourceFile);
|
|
40
|
+
const getSinglePageResolver = async ({ functionsDir, sourceFiles, }) => {
|
|
41
|
+
const dependencies = await Promise.all(sourceFiles.map((sourceFile) => (0, files_1.getDependenciesOfFile)(sourceFile)));
|
|
42
42
|
// We don't need the actual name, just the relative path.
|
|
43
43
|
const functionDir = (0, pathe_1.resolve)(functionsDir, 'functionName');
|
|
44
|
-
const
|
|
44
|
+
const deduped = [...new Set(dependencies.flat())];
|
|
45
|
+
const pageFiles = [...sourceFiles, ...deduped]
|
|
45
46
|
.map((file) => `require.resolve('${(0, pathe_1.relative)(functionDir, file)}')`)
|
|
46
47
|
.sort();
|
|
47
48
|
return (0, outdent_1.outdent /* javascript */) `
|