@netlify/plugin-nextjs 5.0.0-beta.3 → 5.0.0-beta.4

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.
Files changed (31) hide show
  1. package/dist/build/cache.js +4 -4
  2. package/dist/build/content/prerendered.js +5 -5
  3. package/dist/build/content/server.js +5 -5
  4. package/dist/build/content/static.js +5 -5
  5. package/dist/build/functions/edge.js +6 -6
  6. package/dist/build/functions/server.js +7 -7
  7. package/dist/build/image-cdn.js +4 -4
  8. package/dist/build/plugin-context.js +4 -4
  9. package/dist/esm-chunks/{chunk-5SZ5JD6J.js → chunk-6HBXWNZS.js} +27 -9
  10. package/dist/esm-chunks/{chunk-S5JXJCXP.js → chunk-DZM5AUXX.js} +4 -4
  11. package/dist/esm-chunks/{chunk-H46DW7YI.js → chunk-EPSI5TTB.js} +2 -2
  12. package/dist/esm-chunks/{chunk-TJKO3X6O.js → chunk-IZY5TPZE.js} +27 -3
  13. package/dist/esm-chunks/{chunk-4AJYXTWN.js → chunk-K233JI4O.js} +2 -2
  14. package/dist/esm-chunks/{chunk-Z7ZMLVTM.js → chunk-KMPIVUVT.js} +4 -4
  15. package/dist/esm-chunks/{chunk-AVWFCGVE.js → chunk-MFN4GH7U.js} +3 -3
  16. package/dist/esm-chunks/{chunk-B6QMRLBH.js → chunk-NE4HYI2D.js} +3 -3
  17. package/dist/esm-chunks/{chunk-RSKIKBZH.js → chunk-WELZ7LFO.js} +2 -2
  18. package/dist/esm-chunks/{chunk-ALO2SSMH.js → chunk-X4Q4MYBW.js} +39 -28
  19. package/dist/esm-chunks/{chunk-GHDGGK6V.js → chunk-X7XIMV6B.js} +3 -3
  20. package/dist/esm-chunks/{chunk-XQ65S4R2.js → chunk-XA2CZH5Y.js} +2 -2
  21. package/dist/esm-chunks/{chunk-FFCTA32Q.js → chunk-XC7T747I.js} +20 -14
  22. package/dist/esm-chunks/{chunk-OIL5MDCV.js → chunk-XIP2W57K.js} +12 -5
  23. package/dist/esm-chunks/{chunk-SMSOJ2OS.js → chunk-YG3G7B2X.js} +2 -2
  24. package/dist/index.js +18 -14
  25. package/dist/run/config.js +5 -5
  26. package/dist/run/constants.js +4 -4
  27. package/dist/run/handlers/server.js +14 -12
  28. package/dist/run/headers.js +4 -4
  29. package/dist/run/revalidate.js +4 -4
  30. package/dist/run/systemlog.js +4 -4
  31. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  restoreBuildCache,
9
9
  saveBuildCache
10
- } from "../esm-chunks/chunk-XQ65S4R2.js";
11
- import "../esm-chunks/chunk-RSKIKBZH.js";
10
+ } from "../esm-chunks/chunk-XA2CZH5Y.js";
11
+ import "../esm-chunks/chunk-WELZ7LFO.js";
12
12
  export {
13
13
  restoreBuildCache,
14
14
  saveBuildCache
@@ -1,15 +1,15 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  copyFetchContent,
9
9
  copyPrerenderedContent
10
- } from "../../esm-chunks/chunk-S5JXJCXP.js";
11
- import "../../esm-chunks/chunk-AVWFCGVE.js";
12
- import "../../esm-chunks/chunk-RSKIKBZH.js";
10
+ } from "../../esm-chunks/chunk-DZM5AUXX.js";
11
+ import "../../esm-chunks/chunk-MFN4GH7U.js";
12
+ import "../../esm-chunks/chunk-WELZ7LFO.js";
13
13
  export {
14
14
  copyFetchContent,
15
15
  copyPrerenderedContent
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -8,9 +8,9 @@ import {
8
8
  copyNextDependencies,
9
9
  copyNextServerCode,
10
10
  writeTagsManifest
11
- } from "../../esm-chunks/chunk-5SZ5JD6J.js";
12
- import "../../esm-chunks/chunk-AVWFCGVE.js";
13
- import "../../esm-chunks/chunk-RSKIKBZH.js";
11
+ } from "../../esm-chunks/chunk-6HBXWNZS.js";
12
+ import "../../esm-chunks/chunk-MFN4GH7U.js";
13
+ import "../../esm-chunks/chunk-WELZ7LFO.js";
14
14
  export {
15
15
  copyNextDependencies,
16
16
  copyNextServerCode,
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -9,9 +9,9 @@ import {
9
9
  copyStaticContent,
10
10
  publishStaticDir,
11
11
  unpublishStaticDir
12
- } from "../../esm-chunks/chunk-Z7ZMLVTM.js";
13
- import "../../esm-chunks/chunk-AVWFCGVE.js";
14
- import "../../esm-chunks/chunk-RSKIKBZH.js";
12
+ } from "../../esm-chunks/chunk-KMPIVUVT.js";
13
+ import "../../esm-chunks/chunk-MFN4GH7U.js";
14
+ import "../../esm-chunks/chunk-WELZ7LFO.js";
15
15
  export {
16
16
  copyStaticAssets,
17
17
  copyStaticContent,
@@ -1,15 +1,15 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  createEdgeHandlers
9
- } from "../../esm-chunks/chunk-FFCTA32Q.js";
10
- import "../../esm-chunks/chunk-AVWFCGVE.js";
11
- import "../../esm-chunks/chunk-TJKO3X6O.js";
12
- import "../../esm-chunks/chunk-RSKIKBZH.js";
9
+ } from "../../esm-chunks/chunk-XC7T747I.js";
10
+ import "../../esm-chunks/chunk-MFN4GH7U.js";
11
+ import "../../esm-chunks/chunk-IZY5TPZE.js";
12
+ import "../../esm-chunks/chunk-WELZ7LFO.js";
13
13
  export {
14
14
  createEdgeHandlers
15
15
  };
@@ -1,16 +1,16 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  createServerHandler
9
- } from "../../esm-chunks/chunk-ALO2SSMH.js";
10
- import "../../esm-chunks/chunk-5SZ5JD6J.js";
11
- import "../../esm-chunks/chunk-AVWFCGVE.js";
12
- import "../../esm-chunks/chunk-TJKO3X6O.js";
13
- import "../../esm-chunks/chunk-RSKIKBZH.js";
9
+ } from "../../esm-chunks/chunk-X4Q4MYBW.js";
10
+ import "../../esm-chunks/chunk-6HBXWNZS.js";
11
+ import "../../esm-chunks/chunk-MFN4GH7U.js";
12
+ import "../../esm-chunks/chunk-IZY5TPZE.js";
13
+ import "../../esm-chunks/chunk-WELZ7LFO.js";
14
14
  export {
15
15
  createServerHandler
16
16
  };
@@ -1,13 +1,13 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  setImageConfig
9
- } from "../esm-chunks/chunk-H46DW7YI.js";
10
- import "../esm-chunks/chunk-RSKIKBZH.js";
9
+ } from "../esm-chunks/chunk-EPSI5TTB.js";
10
+ import "../esm-chunks/chunk-WELZ7LFO.js";
11
11
  export {
12
12
  setImageConfig
13
13
  };
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -8,8 +8,8 @@ import {
8
8
  EDGE_HANDLER_NAME,
9
9
  PluginContext,
10
10
  SERVER_HANDLER_NAME
11
- } from "../esm-chunks/chunk-TJKO3X6O.js";
12
- import "../esm-chunks/chunk-RSKIKBZH.js";
11
+ } from "../esm-chunks/chunk-IZY5TPZE.js";
12
+ import "../esm-chunks/chunk-WELZ7LFO.js";
13
13
  export {
14
14
  EDGE_HANDLER_NAME,
15
15
  PluginContext,
@@ -1,15 +1,15 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "./chunk-AVWFCGVE.js";
9
+ } from "./chunk-MFN4GH7U.js";
10
10
  import {
11
11
  __toESM
12
- } from "./chunk-RSKIKBZH.js";
12
+ } from "./chunk-WELZ7LFO.js";
13
13
 
14
14
  // src/build/content/server.ts
15
15
  var import_fast_glob = __toESM(require_out(), 1);
@@ -17,7 +17,7 @@ import { existsSync } from "node:fs";
17
17
  import { cp, mkdir, readFile, readdir, readlink, symlink, writeFile } from "node:fs/promises";
18
18
  import { dirname, join } from "node:path";
19
19
  var copyNextServerCode = async (ctx) => {
20
- const srcDir = join(ctx.publishDir, "standalone/.next");
20
+ const srcDir = join(ctx.standaloneDir, ".next");
21
21
  const destDir = join(ctx.serverHandlerDir, ".next");
22
22
  const paths = await (0, import_fast_glob.default)(
23
23
  [`*`, `server/*`, `server/chunks/*`, `server/edge-chunks/*`, `server/+(app|pages)/**/*.js`],
@@ -64,10 +64,28 @@ async function recreateNodeModuleSymlinks(src, dest, org) {
64
64
  );
65
65
  }
66
66
  var copyNextDependencies = async (ctx) => {
67
- const srcDir = join(ctx.publishDir, "standalone/node_modules");
68
- const destDir = join(ctx.serverHandlerDir, "node_modules");
69
- await cp(srcDir, destDir, { recursive: true });
70
- await recreateNodeModuleSymlinks(ctx.resolve("node_modules"), destDir);
67
+ const entries = await readdir(ctx.standaloneDir);
68
+ const promises = entries.map(async (entry) => {
69
+ if (entry === "package.json" || entry === ".next") {
70
+ return;
71
+ }
72
+ const src = join(ctx.standaloneDir, entry);
73
+ const dest = join(ctx.serverHandlerDir, entry);
74
+ await cp(src, dest, { recursive: true });
75
+ if (entry === "node_modules") {
76
+ await recreateNodeModuleSymlinks(ctx.resolve("node_modules"), dest);
77
+ }
78
+ });
79
+ const rootSrcDir = join(ctx.standaloneRootDir, "node_modules");
80
+ const rootDestDir = join(ctx.serverHandlerRootDir, "node_modules");
81
+ if (existsSync(rootSrcDir) && ctx.standaloneRootDir !== ctx.standaloneDir) {
82
+ promises.push(
83
+ cp(rootSrcDir, rootDestDir, { recursive: true }).then(
84
+ () => recreateNodeModuleSymlinks(ctx.resolve("node_modules"), rootDestDir)
85
+ )
86
+ );
87
+ }
88
+ await Promise.all(promises);
71
89
  };
72
90
  var writeTagsManifest = async (ctx) => {
73
91
  const manifest = await ctx.getPrerenderManifest();
@@ -1,15 +1,15 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "./chunk-AVWFCGVE.js";
9
+ } from "./chunk-MFN4GH7U.js";
10
10
  import {
11
11
  __toESM
12
- } from "./chunk-RSKIKBZH.js";
12
+ } from "./chunk-WELZ7LFO.js";
13
13
 
14
14
  // src/build/content/prerendered.ts
15
15
  var import_fast_glob = __toESM(require_out(), 1);
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -28,6 +28,24 @@ var PluginContext = class {
28
28
  get publishDir() {
29
29
  return resolve(this.constants.PUBLISH_DIR);
30
30
  }
31
+ /**
32
+ * Relative package path in non monorepo setups this is an empty string
33
+ * @example ''
34
+ * @example 'apps/my-app'
35
+ */
36
+ get packagePath() {
37
+ return this.constants.PACKAGE_PATH || "";
38
+ }
39
+ /**
40
+ * Retrieves the root of the `.next/standalone` directory
41
+ */
42
+ get standaloneRootDir() {
43
+ return join(this.publishDir, "standalone");
44
+ }
45
+ /** Retrieves the `.next/standalone/` directory monorepo aware */
46
+ get standaloneDir() {
47
+ return join(this.standaloneRootDir, this.constants.PACKAGE_PATH || "");
48
+ }
31
49
  /**
32
50
  * Absolute path of the directory that is published and deployed to the Netlify CDN
33
51
  * Will be swapped with the publish directory
@@ -51,9 +69,15 @@ var PluginContext = class {
51
69
  return this.resolve(".netlify/functions-internal");
52
70
  }
53
71
  /** Absolute path of the server handler */
54
- get serverHandlerDir() {
72
+ get serverHandlerRootDir() {
55
73
  return join(this.serverFunctionsDir, SERVER_HANDLER_NAME);
56
74
  }
75
+ get serverHandlerDir() {
76
+ return join(this.serverHandlerRootDir, this.constants.PACKAGE_PATH || "");
77
+ }
78
+ get nextServerHandler() {
79
+ return join(this.constants.PACKAGE_PATH || "", "dist/run/handlers/server.js");
80
+ }
57
81
  /**
58
82
  * Absolute path of the directory containing the files for deno edge functions
59
83
  * `.netlify/edge-functions`
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -1,15 +1,15 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "./chunk-AVWFCGVE.js";
9
+ } from "./chunk-MFN4GH7U.js";
10
10
  import {
11
11
  __toESM
12
- } from "./chunk-RSKIKBZH.js";
12
+ } from "./chunk-WELZ7LFO.js";
13
13
 
14
14
  // src/build/content/static.ts
15
15
  var import_fast_glob = __toESM(require_out(), 1);
@@ -1,13 +1,13 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  __commonJS,
9
9
  __require
10
- } from "./chunk-RSKIKBZH.js";
10
+ } from "./chunk-WELZ7LFO.js";
11
11
 
12
12
  // node_modules/fast-glob/out/utils/array.js
13
13
  var require_array = __commonJS({
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -8,7 +8,7 @@ import {
8
8
  __commonJS,
9
9
  __require,
10
10
  __toESM
11
- } from "./chunk-RSKIKBZH.js";
11
+ } from "./chunk-WELZ7LFO.js";
12
12
 
13
13
  // node_modules/is-promise/index.js
14
14
  var require_is_promise = __commonJS({
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -8,16 +8,16 @@ import {
8
8
  copyNextDependencies,
9
9
  copyNextServerCode,
10
10
  writeTagsManifest
11
- } from "./chunk-5SZ5JD6J.js";
11
+ } from "./chunk-6HBXWNZS.js";
12
12
  import {
13
13
  require_out
14
- } from "./chunk-AVWFCGVE.js";
14
+ } from "./chunk-MFN4GH7U.js";
15
15
  import {
16
16
  SERVER_HANDLER_NAME
17
- } from "./chunk-TJKO3X6O.js";
17
+ } from "./chunk-IZY5TPZE.js";
18
18
  import {
19
19
  __toESM
20
- } from "./chunk-RSKIKBZH.js";
20
+ } from "./chunk-WELZ7LFO.js";
21
21
 
22
22
  // src/build/functions/server.ts
23
23
  var import_fast_glob = __toESM(require_out(), 1);
@@ -33,21 +33,15 @@ var copyHandlerDependencies = async (ctx) => {
33
33
  };
34
34
  var writeHandlerManifest = async (ctx) => {
35
35
  await writeFile(
36
- join(ctx.serverHandlerDir, `${SERVER_HANDLER_NAME}.json`),
36
+ join(ctx.serverHandlerRootDir, `${SERVER_HANDLER_NAME}.json`),
37
37
  JSON.stringify({
38
38
  config: {
39
39
  name: "Next.js Server Handler",
40
40
  generator: `${ctx.pluginName}@${ctx.pluginVersion}`,
41
41
  nodeBundler: "none",
42
- includedFiles: [
43
- `${SERVER_HANDLER_NAME}*`,
44
- "package.json",
45
- "dist/**",
46
- ".next/**",
47
- ".netlify/**",
48
- "node_modules/**"
49
- ],
50
- includedFilesBasePath: ctx.serverHandlerDir
42
+ // the folders can vary in monorepos based on the folder structure of the user so we have to glob all
43
+ includedFiles: ["**"],
44
+ includedFilesBasePath: ctx.serverHandlerRootDir
51
45
  },
52
46
  version: 1
53
47
  }),
@@ -55,21 +49,38 @@ var writeHandlerManifest = async (ctx) => {
55
49
  );
56
50
  };
57
51
  var writePackageMetadata = async (ctx) => {
58
- await writeFile(join(ctx.serverHandlerDir, "package.json"), JSON.stringify({ type: "module" }));
59
- };
60
- var writeHandlerFile = async (ctx) => {
61
52
  await writeFile(
62
- join(ctx.serverHandlerDir, `${SERVER_HANDLER_NAME}.js`),
63
- `
64
- import handler from './dist/run/handlers/server.js';
65
- export default handler;
66
- export const config = {
67
- path: '/*',
68
- preferStatic: true
69
- };
70
- `
53
+ join(ctx.serverHandlerRootDir, "package.json"),
54
+ JSON.stringify({ type: "module" })
71
55
  );
72
56
  };
57
+ var getHandlerFile = (ctx) => {
58
+ const config = `
59
+ export const config = {
60
+ path: '/*',
61
+ preferStatic: true,
62
+ }`;
63
+ if (ctx.packagePath.length !== 0) {
64
+ return `process.chdir('${join("/var/task", ctx.packagePath)}');
65
+
66
+ let cachedHandler;
67
+ export default async function(...args) {
68
+ if (!cachedHandler) {
69
+ const { default: handler } = await import('./${ctx.nextServerHandler}');
70
+ cachedHandler = handler;
71
+ }
72
+ return cachedHandler(...args)
73
+ };
74
+
75
+ ${config}`;
76
+ }
77
+ return `import handler from './dist/run/handlers/server.js';
78
+ export default handler;
79
+ ${config}`;
80
+ };
81
+ var writeHandlerFile = async (ctx) => {
82
+ await writeFile(join(ctx.serverHandlerRootDir, `${SERVER_HANDLER_NAME}.mjs`), getHandlerFile(ctx));
83
+ };
73
84
  var createServerHandler = async (ctx) => {
74
85
  await rm(ctx.serverFunctionsDir, { recursive: true, force: true });
75
86
  await mkdir(join(ctx.serverHandlerDir, ".netlify"), { recursive: true });
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -8,7 +8,7 @@ import {
8
8
  __commonJS,
9
9
  __require,
10
10
  __toESM
11
- } from "./chunk-RSKIKBZH.js";
11
+ } from "./chunk-WELZ7LFO.js";
12
12
 
13
13
  // node_modules/@netlify/functions/dist/lib/system_logger.js
14
14
  var require_system_logger = __commonJS({
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -1,18 +1,18 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  require_out
9
- } from "./chunk-AVWFCGVE.js";
9
+ } from "./chunk-MFN4GH7U.js";
10
10
  import {
11
11
  EDGE_HANDLER_NAME
12
- } from "./chunk-TJKO3X6O.js";
12
+ } from "./chunk-IZY5TPZE.js";
13
13
  import {
14
14
  __toESM
15
- } from "./chunk-RSKIKBZH.js";
15
+ } from "./chunk-WELZ7LFO.js";
16
16
 
17
17
  // src/build/functions/edge.ts
18
18
  var import_fast_glob = __toESM(require_out(), 1);
@@ -61,7 +61,7 @@ var writeHandlerFile = async (ctx, { matchers, name }) => {
61
61
  };
62
62
  var copyHandlerDependencies = async (ctx, { name, files }) => {
63
63
  const edgeRuntimePath = join(ctx.pluginDir, "edge-runtime");
64
- const srcDir = ctx.resolve(".next/standalone/.next");
64
+ const srcDir = join(ctx.standaloneDir, ".next");
65
65
  const shimPath = join(edgeRuntimePath, "shim/index.js");
66
66
  const shim = await readFile(shimPath, "utf8");
67
67
  const imports = `import './edge-runtime-webpack.js';`;
@@ -85,13 +85,19 @@ var createEdgeHandler = async (ctx, definition) => {
85
85
  await writeHandlerFile(ctx, definition);
86
86
  };
87
87
  var getHandlerName = ({ name }) => `${EDGE_HANDLER_NAME}-${name.replace(/\W/g, "-")}`;
88
- var buildHandlerDefinition = (ctx, { name, matchers, page }) => ({
89
- function: getHandlerName({ name }),
90
- name: name === "middleware" ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`,
91
- pattern: matchers[0].regexp,
92
- cache: name === "middleware" ? void 0 : "manual",
93
- generator: `${ctx.pluginName}@${ctx.pluginVersion}`
94
- });
88
+ var buildHandlerDefinition = (ctx, { name, matchers, page }) => {
89
+ const fun = getHandlerName({ name });
90
+ const funName = name === "middleware" ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`;
91
+ const cache = name === "middleware" ? void 0 : "manual";
92
+ const generator = `${ctx.pluginName}@${ctx.pluginVersion}`;
93
+ return matchers.map((matcher) => ({
94
+ function: fun,
95
+ name: funName,
96
+ pattern: matcher.regexp,
97
+ cache,
98
+ generator
99
+ }));
100
+ };
95
101
  var createEdgeHandlers = async (ctx) => {
96
102
  await rm(ctx.edgeFunctionsDir, { recursive: true, force: true });
97
103
  const nextManifest = await ctx.getMiddlewareManifest();
@@ -100,7 +106,7 @@ var createEdgeHandlers = async (ctx) => {
100
106
  // ...Object.values(nextManifest.functions)
101
107
  ];
102
108
  await Promise.all(nextDefinitions.map((def) => createEdgeHandler(ctx, def)));
103
- const netlifyDefinitions = nextDefinitions.map((def) => buildHandlerDefinition(ctx, def));
109
+ const netlifyDefinitions = nextDefinitions.flatMap((def) => buildHandlerDefinition(ctx, def));
104
110
  const netlifyManifest = {
105
111
  version: 1,
106
112
  functions: netlifyDefinitions
@@ -1,24 +1,31 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  PLUGIN_DIR
9
- } from "./chunk-4AJYXTWN.js";
9
+ } from "./chunk-K233JI4O.js";
10
10
 
11
11
  // src/run/config.ts
12
+ import { existsSync } from "node:fs";
12
13
  import { readFile } from "node:fs/promises";
13
- import { resolve } from "node:path";
14
+ import { join, resolve } from "node:path";
14
15
  var getRunConfig = async () => {
15
16
  return JSON.parse(await readFile(resolve(".next/required-server-files.json"), "utf-8")).config;
16
17
  };
17
18
  var setRunConfig = (config) => {
19
+ const cacheHandler = join(PLUGIN_DIR, "dist/run/handlers/cache.cjs");
20
+ if (!existsSync(cacheHandler)) {
21
+ throw new Error(`Cache handler not found at ${cacheHandler}`);
22
+ }
18
23
  config.experimental = {
19
24
  ...config.experimental,
20
- incrementalCacheHandlerPath: `${PLUGIN_DIR}/dist/run/handlers/cache.cjs`
25
+ incrementalCacheHandlerPath: cacheHandler
21
26
  };
27
+ config.cacheHandler = cacheHandler;
28
+ config.cacheMaxMemorySize = 0;
22
29
  process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(config);
23
30
  };
24
31
  var getTagsManifest = async () => {
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
package/dist/index.js CHANGED
@@ -1,44 +1,46 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  copyFetchContent,
9
9
  copyPrerenderedContent
10
- } from "./esm-chunks/chunk-S5JXJCXP.js";
10
+ } from "./esm-chunks/chunk-DZM5AUXX.js";
11
11
  import {
12
12
  copyStaticAssets,
13
13
  copyStaticContent,
14
14
  publishStaticDir,
15
15
  unpublishStaticDir
16
- } from "./esm-chunks/chunk-Z7ZMLVTM.js";
16
+ } from "./esm-chunks/chunk-KMPIVUVT.js";
17
17
  import {
18
18
  createEdgeHandlers
19
- } from "./esm-chunks/chunk-FFCTA32Q.js";
19
+ } from "./esm-chunks/chunk-XC7T747I.js";
20
20
  import {
21
21
  createServerHandler
22
- } from "./esm-chunks/chunk-ALO2SSMH.js";
23
- import "./esm-chunks/chunk-5SZ5JD6J.js";
24
- import "./esm-chunks/chunk-AVWFCGVE.js";
22
+ } from "./esm-chunks/chunk-X4Q4MYBW.js";
23
+ import "./esm-chunks/chunk-6HBXWNZS.js";
24
+ import "./esm-chunks/chunk-MFN4GH7U.js";
25
25
  import {
26
26
  restoreBuildCache,
27
27
  saveBuildCache
28
- } from "./esm-chunks/chunk-XQ65S4R2.js";
28
+ } from "./esm-chunks/chunk-XA2CZH5Y.js";
29
29
  import {
30
30
  setImageConfig
31
- } from "./esm-chunks/chunk-H46DW7YI.js";
31
+ } from "./esm-chunks/chunk-EPSI5TTB.js";
32
32
  import {
33
33
  PluginContext
34
- } from "./esm-chunks/chunk-TJKO3X6O.js";
35
- import "./esm-chunks/chunk-RSKIKBZH.js";
34
+ } from "./esm-chunks/chunk-IZY5TPZE.js";
35
+ import "./esm-chunks/chunk-WELZ7LFO.js";
36
36
 
37
37
  // src/index.ts
38
38
  import { existsSync } from "node:fs";
39
39
  var onPreBuild = async (options) => {
40
40
  process.env.NEXT_PRIVATE_STANDALONE = "true";
41
- await restoreBuildCache(new PluginContext(options));
41
+ if (!options.constants.IS_LOCAL) {
42
+ await restoreBuildCache(new PluginContext(options));
43
+ }
42
44
  };
43
45
  var onBuild = async (options) => {
44
46
  const ctx = new PluginContext(options);
@@ -46,7 +48,9 @@ var onBuild = async (options) => {
46
48
  ctx.failBuild("Publish directory not found, please check your netlify.toml");
47
49
  }
48
50
  await setImageConfig(ctx);
49
- await saveBuildCache(ctx);
51
+ if (!options.constants.IS_LOCAL) {
52
+ await saveBuildCache(ctx);
53
+ }
50
54
  await Promise.all([
51
55
  copyStaticAssets(ctx),
52
56
  copyStaticContent(ctx),
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -8,9 +8,9 @@ import {
8
8
  getRunConfig,
9
9
  getTagsManifest,
10
10
  setRunConfig
11
- } from "../esm-chunks/chunk-OIL5MDCV.js";
12
- import "../esm-chunks/chunk-4AJYXTWN.js";
13
- import "../esm-chunks/chunk-RSKIKBZH.js";
11
+ } from "../esm-chunks/chunk-XIP2W57K.js";
12
+ import "../esm-chunks/chunk-K233JI4O.js";
13
+ import "../esm-chunks/chunk-WELZ7LFO.js";
14
14
  export {
15
15
  getRunConfig,
16
16
  getTagsManifest,
@@ -1,14 +1,14 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  MODULE_DIR,
9
9
  PLUGIN_DIR
10
- } from "../esm-chunks/chunk-4AJYXTWN.js";
11
- import "../esm-chunks/chunk-RSKIKBZH.js";
10
+ } from "../esm-chunks/chunk-K233JI4O.js";
11
+ import "../esm-chunks/chunk-WELZ7LFO.js";
12
12
  export {
13
13
  MODULE_DIR,
14
14
  PLUGIN_DIR
@@ -1,30 +1,30 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  import_internal
9
- } from "../../esm-chunks/chunk-GHDGGK6V.js";
9
+ } from "../../esm-chunks/chunk-X7XIMV6B.js";
10
10
  import {
11
11
  getTagsManifest
12
- } from "../../esm-chunks/chunk-OIL5MDCV.js";
13
- import "../../esm-chunks/chunk-4AJYXTWN.js";
12
+ } from "../../esm-chunks/chunk-XIP2W57K.js";
13
+ import "../../esm-chunks/chunk-K233JI4O.js";
14
14
  import {
15
15
  adjustDateHeader,
16
16
  handleNextCacheHeader,
17
17
  setCacheControlHeaders,
18
18
  setCacheTagsHeaders,
19
19
  setVaryHeaders
20
- } from "../../esm-chunks/chunk-SMSOJ2OS.js";
20
+ } from "../../esm-chunks/chunk-YG3G7B2X.js";
21
21
  import {
22
22
  nextResponseProxy
23
- } from "../../esm-chunks/chunk-B6QMRLBH.js";
23
+ } from "../../esm-chunks/chunk-NE4HYI2D.js";
24
24
  import {
25
25
  __commonJS,
26
26
  __toESM
27
- } from "../../esm-chunks/chunk-RSKIKBZH.js";
27
+ } from "../../esm-chunks/chunk-WELZ7LFO.js";
28
28
 
29
29
  // node_modules/node-inspect-extracted/dist/inspect.js
30
30
  var require_inspect = __commonJS({
@@ -1966,6 +1966,7 @@ var ComputeJsIncomingMessage = class extends Readable {
1966
1966
  this._consuming = true;
1967
1967
  }
1968
1968
  if (this._stream == null) {
1969
+ this.complete = true;
1969
1970
  this.push(null);
1970
1971
  return;
1971
1972
  }
@@ -1973,6 +1974,7 @@ var ComputeJsIncomingMessage = class extends Readable {
1973
1974
  try {
1974
1975
  const data = await reader.read();
1975
1976
  if (data.done) {
1977
+ this.complete = true;
1976
1978
  this.push(null);
1977
1979
  } else {
1978
1980
  this.push(data.value);
@@ -2425,13 +2427,13 @@ var ComputeJsOutgoingMessage = class extends Writable {
2425
2427
  }
2426
2428
  const { statusCode: statusCodeText, statusMessage } = (_b2 = statusLineResult.groups) !== null && _b2 !== void 0 ? _b2 : {};
2427
2429
  const statusCode = parseInt(statusCodeText, 10);
2428
- const headers = {};
2430
+ const headers = [];
2429
2431
  for (const headerLine of headerLines) {
2430
2432
  if (headerLine !== "") {
2431
2433
  const pos = headerLine.indexOf(": ");
2432
2434
  const k = headerLine.slice(0, pos);
2433
2435
  const v = headerLine.slice(pos + 2);
2434
- headers[k] = v;
2436
+ headers.push([k, v]);
2435
2437
  }
2436
2438
  }
2437
2439
  this._headerSent = true;
@@ -3186,8 +3188,8 @@ var ComputeJsServerResponse = class _ComputeJsServerResponse extends ComputeJsOu
3186
3188
  }
3187
3189
  _toComputeResponse(status, statusText, sentHeaders, initialDataChunks, finished) {
3188
3190
  const headers = new Headers();
3189
- for (const [key, value] of Object.entries(sentHeaders)) {
3190
- headers.append(key, value);
3191
+ for (const [header, value] of sentHeaders) {
3192
+ headers.append(header, value);
3191
3193
  }
3192
3194
  const _this = this;
3193
3195
  const body = this._hasBody ? new ReadableStream({
@@ -1,6 +1,6 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
@@ -10,8 +10,8 @@ import {
10
10
  setCacheControlHeaders,
11
11
  setCacheTagsHeaders,
12
12
  setVaryHeaders
13
- } from "../esm-chunks/chunk-SMSOJ2OS.js";
14
- import "../esm-chunks/chunk-RSKIKBZH.js";
13
+ } from "../esm-chunks/chunk-YG3G7B2X.js";
14
+ import "../esm-chunks/chunk-WELZ7LFO.js";
15
15
  export {
16
16
  adjustDateHeader,
17
17
  handleNextCacheHeader,
@@ -1,13 +1,13 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  nextResponseProxy
9
- } from "../esm-chunks/chunk-B6QMRLBH.js";
10
- import "../esm-chunks/chunk-RSKIKBZH.js";
9
+ } from "../esm-chunks/chunk-NE4HYI2D.js";
10
+ import "../esm-chunks/chunk-WELZ7LFO.js";
11
11
  export {
12
12
  nextResponseProxy
13
13
  };
@@ -1,13 +1,13 @@
1
1
 
2
- const require = await (async () => {
3
- const { createRequire } = await import("node:module");
2
+ var require = await (async () => {
3
+ var { createRequire } = await import("node:module");
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
7
  import {
8
8
  import_internal
9
- } from "../esm-chunks/chunk-GHDGGK6V.js";
10
- import "../esm-chunks/chunk-RSKIKBZH.js";
9
+ } from "../esm-chunks/chunk-X7XIMV6B.js";
10
+ import "../esm-chunks/chunk-WELZ7LFO.js";
11
11
  var export_LogLevel = import_internal.LogLevel;
12
12
  var export_logger = import_internal.systemLogger;
13
13
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.0.0-beta.4",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",