@netlify/plugin-nextjs 5.10.0 → 5.10.1

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 (43) hide show
  1. package/dist/build/advanced-api-routes.js +136 -4
  2. package/dist/build/cache.js +25 -4
  3. package/dist/build/content/prerendered.js +293 -11
  4. package/dist/build/content/server.js +219 -11
  5. package/dist/build/content/static.js +112 -15
  6. package/dist/build/functions/edge.js +540 -7
  7. package/dist/build/functions/server.js +130 -11
  8. package/dist/build/image-cdn.js +1599 -3
  9. package/dist/build/plugin-context.js +292 -6
  10. package/dist/build/verification.js +104 -9
  11. package/dist/esm-chunks/{package-F536DQ6H.js → package-UN6EVEHD.js} +1 -1
  12. package/dist/index.js +19 -40
  13. package/dist/run/config.js +1 -4
  14. package/dist/run/constants.js +7 -5
  15. package/dist/run/handlers/cache.cjs +44 -1654
  16. package/dist/run/handlers/server.js +14 -33
  17. package/dist/run/handlers/tracer.cjs +2 -114
  18. package/dist/run/handlers/tracing.js +2 -4
  19. package/dist/run/handlers/wait-until.cjs +2 -116
  20. package/dist/run/headers.js +198 -10
  21. package/dist/run/next.cjs +11 -1623
  22. package/dist/run/regional-blob-store.cjs +37 -4
  23. package/dist/run/revalidate.js +24 -3
  24. package/dist/shared/blobkey.js +15 -3
  25. package/package.json +1 -1
  26. package/dist/esm-chunks/chunk-3RQSTU2O.js +0 -554
  27. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  28. package/dist/esm-chunks/chunk-AMY4NOT5.js +0 -1610
  29. package/dist/esm-chunks/chunk-DLBTTDNJ.js +0 -309
  30. package/dist/esm-chunks/chunk-DLVROEVU.js +0 -144
  31. package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
  32. package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
  33. package/dist/esm-chunks/chunk-K4RDUZYO.js +0 -609
  34. package/dist/esm-chunks/chunk-SGXRYMYQ.js +0 -127
  35. package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
  36. package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
  37. package/dist/esm-chunks/chunk-VTKZZRGT.js +0 -132
  38. package/dist/esm-chunks/chunk-WHUPSPWV.js +0 -73
  39. package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
  40. package/dist/esm-chunks/chunk-YMNWVS6T.js +0 -218
  41. package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
  42. package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
  43. package/dist/esm-chunks/next-7JK63CHT.js +0 -567
@@ -1,148 +0,0 @@
1
-
2
- var require = await (async () => {
3
- var { createRequire } = await import("node:module");
4
- return createRequire(import.meta.url);
5
- })();
6
-
7
- import {
8
- __require
9
- } from "./chunk-OEQOKJGE.js";
10
-
11
- // src/build/advanced-api-routes.ts
12
- import { existsSync } from "node:fs";
13
- import { readFile } from "node:fs/promises";
14
- import { join } from "node:path";
15
- var ApiRouteType = /* @__PURE__ */ ((ApiRouteType2) => {
16
- ApiRouteType2["SCHEDULED"] = "experimental-scheduled";
17
- ApiRouteType2["BACKGROUND"] = "experimental-background";
18
- return ApiRouteType2;
19
- })(ApiRouteType || {});
20
- async function getAPIRoutesConfigs(ctx) {
21
- const uniqueApiRoutes = /* @__PURE__ */ new Set();
22
- const functionsConfigManifestPath = join(
23
- ctx.publishDir,
24
- "server",
25
- "functions-config-manifest.json"
26
- );
27
- if (existsSync(functionsConfigManifestPath)) {
28
- const functionsConfigManifest = JSON.parse(
29
- await readFile(functionsConfigManifestPath, "utf-8")
30
- );
31
- for (const apiRoute of Object.keys(functionsConfigManifest.functions)) {
32
- uniqueApiRoutes.add(apiRoute);
33
- }
34
- }
35
- const pagesManifestPath = join(ctx.publishDir, "server", "pages-manifest.json");
36
- if (existsSync(pagesManifestPath)) {
37
- const pagesManifest = JSON.parse(await readFile(pagesManifestPath, "utf-8"));
38
- for (const route of Object.keys(pagesManifest)) {
39
- if (route.startsWith("/api/")) {
40
- uniqueApiRoutes.add(route);
41
- }
42
- }
43
- }
44
- if (uniqueApiRoutes.size === 0) {
45
- return [];
46
- }
47
- const appDir = ctx.resolveFromSiteDir(".");
48
- const pagesDir = join(appDir, "pages");
49
- const srcPagesDir = join(appDir, "src", "pages");
50
- const { pageExtensions } = ctx.requiredServerFiles.config;
51
- return Promise.all(
52
- [...uniqueApiRoutes].map(async (apiRoute) => {
53
- const filePath = getSourceFileForPage(apiRoute, [pagesDir, srcPagesDir], pageExtensions);
54
- const sharedFields = {
55
- apiRoute,
56
- filePath,
57
- config: {}
58
- };
59
- if (filePath) {
60
- const config = await extractConfigFromFile(filePath, appDir);
61
- return {
62
- ...sharedFields,
63
- config
64
- };
65
- }
66
- return sharedFields;
67
- })
68
- );
69
- }
70
- var SOURCE_FILE_EXTENSIONS = ["js", "jsx", "ts", "tsx"];
71
- var getSourceFileForPage = (page, roots, pageExtensions = SOURCE_FILE_EXTENSIONS) => {
72
- for (const root of roots) {
73
- for (const extension of pageExtensions) {
74
- const file = join(root, `${page}.${extension}`);
75
- if (existsSync(file)) {
76
- return file;
77
- }
78
- const fileAtFolderIndex = join(root, page, `index.${extension}`);
79
- if (existsSync(fileAtFolderIndex)) {
80
- return fileAtFolderIndex;
81
- }
82
- }
83
- }
84
- };
85
- var findModuleFromBase = ({
86
- paths,
87
- candidates
88
- }) => {
89
- for (const candidate of candidates) {
90
- try {
91
- const modulePath = __require.resolve(candidate, { paths });
92
- if (modulePath) {
93
- return modulePath;
94
- }
95
- } catch {
96
- }
97
- }
98
- for (const candidate of candidates) {
99
- try {
100
- const modulePath = __require.resolve(candidate);
101
- if (modulePath) {
102
- return modulePath;
103
- }
104
- } catch {
105
- }
106
- }
107
- return null;
108
- };
109
- var extractConstValue;
110
- var parseModule;
111
- var extractConfigFromFile = async (apiFilePath, appDir) => {
112
- if (!apiFilePath || !existsSync(apiFilePath)) {
113
- return {};
114
- }
115
- const extractConstValueModulePath = findModuleFromBase({
116
- paths: [appDir],
117
- candidates: ["next/dist/build/analysis/extract-const-value"]
118
- });
119
- const parseModulePath = findModuleFromBase({
120
- paths: [appDir],
121
- candidates: ["next/dist/build/analysis/parse-module"]
122
- });
123
- if (!extractConstValueModulePath || !parseModulePath) {
124
- return {};
125
- }
126
- if (!extractConstValue && extractConstValueModulePath) {
127
- extractConstValue = __require(extractConstValueModulePath);
128
- }
129
- if (!parseModule && parseModulePath) {
130
- parseModule = __require(parseModulePath).parseModule;
131
- }
132
- const { extractExportedConstValue } = extractConstValue;
133
- const fileContent = await readFile(apiFilePath, "utf8");
134
- if (!fileContent.includes("config")) {
135
- return {};
136
- }
137
- const ast = await parseModule(apiFilePath, fileContent);
138
- try {
139
- return extractExportedConstValue(ast, "config");
140
- } catch {
141
- return {};
142
- }
143
- };
144
-
145
- export {
146
- ApiRouteType,
147
- getAPIRoutesConfigs
148
- };
@@ -1,120 +0,0 @@
1
-
2
- var require = await (async () => {
3
- var { createRequire } = await import("node:module");
4
- return createRequire(import.meta.url);
5
- })();
6
-
7
- import {
8
- require_out
9
- } from "./chunk-KGYJQ2U2.js";
10
- import {
11
- getAPIRoutesConfigs
12
- } from "./chunk-ZENB67PD.js";
13
- import {
14
- require_semver
15
- } from "./chunk-APO262HE.js";
16
- import {
17
- __toESM
18
- } from "./chunk-OEQOKJGE.js";
19
-
20
- // src/build/verification.ts
21
- var import_fast_glob = __toESM(require_out(), 1);
22
- var import_semver = __toESM(require_semver(), 1);
23
- import { existsSync } from "node:fs";
24
- import { readFile } from "node:fs/promises";
25
- import { join } from "node:path";
26
- var SUPPORTED_NEXT_VERSIONS = ">=13.5.0";
27
- var verifications = /* @__PURE__ */ new Set();
28
- function verifyPublishDir(ctx) {
29
- if (!existsSync(ctx.publishDir)) {
30
- ctx.failBuild(
31
- `Your publish directory was not found at: ${ctx.publishDir}. Please check your build settings`
32
- );
33
- }
34
- if (ctx.publishDir === ctx.resolveFromPackagePath("")) {
35
- ctx.failBuild(
36
- `Your publish directory cannot be the same as the base directory of your site. Please check your build settings`
37
- );
38
- }
39
- try {
40
- ctx.buildConfig;
41
- } catch {
42
- ctx.failBuild(
43
- "Your publish directory does not contain expected Next.js build output. Please check your build settings"
44
- );
45
- }
46
- if (ctx.buildConfig.output === "standalone" || ctx.buildConfig.output === void 0) {
47
- if (!existsSync(join(ctx.publishDir, "BUILD_ID"))) {
48
- ctx.failBuild(
49
- "Your publish directory does not contain expected Next.js build output. Please check your build settings"
50
- );
51
- }
52
- if (!existsSync(ctx.standaloneRootDir)) {
53
- ctx.failBuild(
54
- `Your publish directory does not contain expected Next.js build output. Please make sure you are using Next.js version (${SUPPORTED_NEXT_VERSIONS})`
55
- );
56
- }
57
- if (ctx.nextVersion && !(0, import_semver.satisfies)(ctx.nextVersion, SUPPORTED_NEXT_VERSIONS, { includePrerelease: true })) {
58
- ctx.failBuild(
59
- `@netlify/plugin-nextjs@5 requires Next.js version ${SUPPORTED_NEXT_VERSIONS}, but found ${ctx.nextVersion}. Please upgrade your project's Next.js version.`
60
- );
61
- }
62
- }
63
- if (ctx.buildConfig.output === "export") {
64
- if (!ctx.exportDetail?.success) {
65
- ctx.failBuild(`Your export failed to build. Please check your build settings`);
66
- }
67
- if (!existsSync(ctx.exportDetail?.outDirectory)) {
68
- ctx.failBuild(
69
- `Your export directory was not found at: ${ctx.exportDetail?.outDirectory}. Please check your build settings`
70
- );
71
- }
72
- }
73
- }
74
- async function verifyAdvancedAPIRoutes(ctx) {
75
- const apiRoutesConfigs = await getAPIRoutesConfigs(ctx);
76
- const unsupportedAPIRoutes = apiRoutesConfigs.filter((apiRouteConfig) => {
77
- return apiRouteConfig.config.type === "experimental-background" /* BACKGROUND */ || apiRouteConfig.config.type === "experimental-scheduled" /* SCHEDULED */;
78
- });
79
- if (unsupportedAPIRoutes.length !== 0) {
80
- ctx.failBuild(
81
- `@netlify/plugin-nextjs@5 does not support advanced API routes. The following API routes should be migrated to Netlify background or scheduled functions:
82
- ${unsupportedAPIRoutes.map((apiRouteConfig) => ` - ${apiRouteConfig.apiRoute} (type: "${apiRouteConfig.config.type}")`).join("\n")}
83
-
84
- Refer to https://ntl.fyi/next-scheduled-bg-function-migration as migration example.`
85
- );
86
- }
87
- }
88
- var formDetectionRegex = /<form[^>]*?\s(netlify|data-netlify)[=>\s]/;
89
- async function verifyNetlifyFormsWorkaround(ctx) {
90
- const srcDir = ctx.resolveFromSiteDir("public");
91
- const paths = await (0, import_fast_glob.glob)("**/*.html", {
92
- cwd: srcDir,
93
- dot: true
94
- });
95
- try {
96
- for (const path of paths) {
97
- const html = await readFile(join(srcDir, path), "utf-8");
98
- if (formDetectionRegex.test(html)) {
99
- verifications.add("netlifyFormsWorkaround");
100
- return;
101
- }
102
- }
103
- } catch (error) {
104
- ctx.failBuild("Failed verifying public files", error);
105
- }
106
- }
107
- function verifyNetlifyForms(ctx, html) {
108
- if (process.env.NETLIFY_NEXT_VERIFY_FORMS !== "0" && process.env.NETLIFY_NEXT_VERIFY_FORMS?.toUpperCase() !== "FALSE" && !verifications.has("netlifyFormsWorkaround") && formDetectionRegex.test(html)) {
109
- ctx.failBuild(
110
- "@netlify/plugin-nextjs@5 requires migration steps to support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example."
111
- );
112
- }
113
- }
114
-
115
- export {
116
- verifyPublishDir,
117
- verifyAdvancedAPIRoutes,
118
- verifyNetlifyFormsWorkaround,
119
- verifyNetlifyForms
120
- };