@netlify/plugin-nextjs 5.10.0 → 5.10.2
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/LICENSE +22 -0
- package/dist/build/advanced-api-routes.js +136 -4
- package/dist/build/cache.js +25 -4
- package/dist/build/content/prerendered.js +293 -11
- package/dist/build/content/server.js +219 -11
- package/dist/build/content/static.js +112 -15
- package/dist/build/functions/edge.js +540 -7
- package/dist/build/functions/server.js +130 -11
- package/dist/build/image-cdn.js +1599 -3
- package/dist/build/plugin-context.js +292 -6
- package/dist/build/verification.js +104 -9
- package/dist/esm-chunks/{package-F536DQ6H.js → package-7HACW4PO.js} +11 -10
- package/dist/index.js +19 -40
- package/dist/run/config.js +6 -7
- package/dist/run/constants.js +7 -5
- package/dist/run/handlers/cache.cjs +93 -1713
- package/dist/run/handlers/request-context.cjs +10 -3
- package/dist/run/handlers/server.js +14 -34
- package/dist/run/handlers/tracer.cjs +17 -116
- package/dist/run/handlers/tracing.js +2 -4
- package/dist/run/handlers/wait-until.cjs +2 -116
- package/dist/run/headers.js +183 -10
- package/dist/run/next.cjs +10 -1625
- package/dist/run/revalidate.js +24 -3
- package/dist/run/{regional-blob-store.cjs → storage/regional-blob-store.cjs} +44 -8
- package/dist/run/storage/request-scoped-in-memory-cache.cjs +1475 -0
- package/dist/run/storage/storage.cjs +84 -0
- package/dist/shared/blob-types.cjs +37 -0
- package/dist/shared/blobkey.js +15 -3
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-3RQSTU2O.js +0 -554
- package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
- package/dist/esm-chunks/chunk-AMY4NOT5.js +0 -1610
- package/dist/esm-chunks/chunk-DLBTTDNJ.js +0 -309
- package/dist/esm-chunks/chunk-DLVROEVU.js +0 -144
- package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
- package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
- package/dist/esm-chunks/chunk-K4RDUZYO.js +0 -609
- package/dist/esm-chunks/chunk-SGXRYMYQ.js +0 -127
- package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
- package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
- package/dist/esm-chunks/chunk-VTKZZRGT.js +0 -132
- package/dist/esm-chunks/chunk-WHUPSPWV.js +0 -73
- package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
- package/dist/esm-chunks/chunk-YMNWVS6T.js +0 -218
- package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
- package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
- package/dist/esm-chunks/next-7JK63CHT.js +0 -567
|
@@ -5,12 +5,298 @@
|
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
require_semver
|
|
9
|
+
} from "../esm-chunks/chunk-APO262HE.js";
|
|
10
|
+
import {
|
|
11
|
+
__toESM
|
|
12
|
+
} from "../esm-chunks/chunk-OEQOKJGE.js";
|
|
13
|
+
|
|
14
|
+
// src/build/plugin-context.ts
|
|
15
|
+
var import_semver = __toESM(require_semver(), 1);
|
|
16
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
17
|
+
import { readFile } from "node:fs/promises";
|
|
18
|
+
import { createRequire } from "node:module";
|
|
19
|
+
import { join, relative, resolve } from "node:path";
|
|
20
|
+
import { join as posixJoin } from "node:path/posix";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
23
|
+
var PLUGIN_DIR = join(MODULE_DIR, "../..");
|
|
24
|
+
var DEFAULT_PUBLISH_DIR = ".next";
|
|
25
|
+
var SERVER_HANDLER_NAME = "___netlify-server-handler";
|
|
26
|
+
var EDGE_HANDLER_NAME = "___netlify-edge-handler";
|
|
27
|
+
var PluginContext = class {
|
|
28
|
+
featureFlags;
|
|
29
|
+
netlifyConfig;
|
|
30
|
+
pluginName;
|
|
31
|
+
pluginVersion;
|
|
32
|
+
utils;
|
|
33
|
+
constants;
|
|
34
|
+
packageJSON;
|
|
35
|
+
/** Absolute path of the next runtime plugin directory */
|
|
36
|
+
pluginDir = PLUGIN_DIR;
|
|
37
|
+
get relPublishDir() {
|
|
38
|
+
return this.constants.PUBLISH_DIR ?? join(this.constants.PACKAGE_PATH || "", DEFAULT_PUBLISH_DIR);
|
|
39
|
+
}
|
|
40
|
+
/** Temporary directory for stashing the build output */
|
|
41
|
+
get tempPublishDir() {
|
|
42
|
+
return this.resolveFromPackagePath(".netlify/.next");
|
|
43
|
+
}
|
|
44
|
+
/** Absolute path of the publish directory */
|
|
45
|
+
get publishDir() {
|
|
46
|
+
return resolve(this.relPublishDir);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Relative package path in non monorepo setups this is an empty string
|
|
50
|
+
* This path is provided by Next.js RequiredServerFiles manifest
|
|
51
|
+
* @example ''
|
|
52
|
+
* @example 'apps/my-app'
|
|
53
|
+
*/
|
|
54
|
+
get relativeAppDir() {
|
|
55
|
+
return this.requiredServerFiles.relativeAppDir ?? "";
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The working directory inside the lambda that is used for monorepos to execute the serverless function
|
|
59
|
+
*/
|
|
60
|
+
get lambdaWorkingDirectory() {
|
|
61
|
+
return join("/var/task", this.distDirParent);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves the root of the `.next/standalone` directory
|
|
65
|
+
*/
|
|
66
|
+
get standaloneRootDir() {
|
|
67
|
+
return join(this.publishDir, "standalone");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The resolved relative next dist directory defaults to `.next`,
|
|
71
|
+
* but can be configured through the next.config.js. For monorepos this will include the packagePath
|
|
72
|
+
* If we need just the plain dist dir use the `nextDistDir`
|
|
73
|
+
*/
|
|
74
|
+
get distDir() {
|
|
75
|
+
const dir = this.buildConfig.distDir ?? DEFAULT_PUBLISH_DIR;
|
|
76
|
+
return relative(process.cwd(), resolve(this.relativeAppDir, dir));
|
|
77
|
+
}
|
|
78
|
+
/** Represents the parent directory of the .next folder or custom distDir */
|
|
79
|
+
get distDirParent() {
|
|
80
|
+
return join(this.distDir, "..");
|
|
81
|
+
}
|
|
82
|
+
/** The `.next` folder or what the custom dist dir is set to */
|
|
83
|
+
get nextDistDir() {
|
|
84
|
+
return relative(this.distDirParent, this.distDir);
|
|
85
|
+
}
|
|
86
|
+
/** Retrieves the `.next/standalone/` directory monorepo aware */
|
|
87
|
+
get standaloneDir() {
|
|
88
|
+
return join(this.standaloneRootDir, this.distDirParent);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Absolute path of the directory that is published and deployed to the Netlify CDN
|
|
92
|
+
* Will be swapped with the publish directory
|
|
93
|
+
* `.netlify/static`
|
|
94
|
+
*/
|
|
95
|
+
get staticDir() {
|
|
96
|
+
return this.resolveFromPackagePath(".netlify/static");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Absolute path of the directory that will be deployed to the blob store
|
|
100
|
+
* region aware: `.netlify/deploy/v1/blobs/deploy`
|
|
101
|
+
* default: `.netlify/blobs/deploy`
|
|
102
|
+
*/
|
|
103
|
+
get blobDir() {
|
|
104
|
+
if (this.useRegionalBlobs) {
|
|
105
|
+
return this.resolveFromPackagePath(".netlify/deploy/v1/blobs/deploy");
|
|
106
|
+
}
|
|
107
|
+
return this.resolveFromPackagePath(".netlify/blobs/deploy");
|
|
108
|
+
}
|
|
109
|
+
get buildVersion() {
|
|
110
|
+
return this.constants.NETLIFY_BUILD_VERSION || "v0.0.0";
|
|
111
|
+
}
|
|
112
|
+
get useRegionalBlobs() {
|
|
113
|
+
const REQUIRED_BUILD_VERSION = ">=29.41.5";
|
|
114
|
+
return (0, import_semver.satisfies)(this.buildVersion, REQUIRED_BUILD_VERSION, { includePrerelease: true });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Absolute path of the directory containing the files for the serverless lambda function
|
|
118
|
+
* `.netlify/functions-internal`
|
|
119
|
+
*/
|
|
120
|
+
get serverFunctionsDir() {
|
|
121
|
+
return this.resolveFromPackagePath(".netlify/functions-internal");
|
|
122
|
+
}
|
|
123
|
+
/** Absolute path of the server handler */
|
|
124
|
+
get serverHandlerRootDir() {
|
|
125
|
+
return join(this.serverFunctionsDir, SERVER_HANDLER_NAME);
|
|
126
|
+
}
|
|
127
|
+
get serverHandlerDir() {
|
|
128
|
+
if (this.relativeAppDir.length === 0) {
|
|
129
|
+
return this.serverHandlerRootDir;
|
|
130
|
+
}
|
|
131
|
+
return join(this.serverHandlerRootDir, this.distDirParent);
|
|
132
|
+
}
|
|
133
|
+
get serverHandlerRuntimeModulesDir() {
|
|
134
|
+
return join(this.serverHandlerDir, ".netlify");
|
|
135
|
+
}
|
|
136
|
+
get nextServerHandler() {
|
|
137
|
+
if (this.relativeAppDir.length !== 0) {
|
|
138
|
+
return join(this.lambdaWorkingDirectory, ".netlify/dist/run/handlers/server.js");
|
|
139
|
+
}
|
|
140
|
+
return "./.netlify/dist/run/handlers/server.js";
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Absolute path of the directory containing the files for deno edge functions
|
|
144
|
+
* `.netlify/edge-functions`
|
|
145
|
+
*/
|
|
146
|
+
get edgeFunctionsDir() {
|
|
147
|
+
return this.resolveFromPackagePath(".netlify/edge-functions");
|
|
148
|
+
}
|
|
149
|
+
/** Absolute path of the edge handler */
|
|
150
|
+
get edgeHandlerDir() {
|
|
151
|
+
return join(this.edgeFunctionsDir, EDGE_HANDLER_NAME);
|
|
152
|
+
}
|
|
153
|
+
constructor(options) {
|
|
154
|
+
this.constants = options.constants;
|
|
155
|
+
this.featureFlags = options.featureFlags;
|
|
156
|
+
this.netlifyConfig = options.netlifyConfig;
|
|
157
|
+
this.packageJSON = JSON.parse(readFileSync(join(PLUGIN_DIR, "package.json"), "utf-8"));
|
|
158
|
+
this.pluginName = this.packageJSON.name;
|
|
159
|
+
this.pluginVersion = this.packageJSON.version;
|
|
160
|
+
this.utils = options.utils;
|
|
161
|
+
}
|
|
162
|
+
/** Resolves a path correctly with mono repository awareness for .netlify directories mainly */
|
|
163
|
+
resolveFromPackagePath(...args) {
|
|
164
|
+
return resolve(this.constants.PACKAGE_PATH || "", ...args);
|
|
165
|
+
}
|
|
166
|
+
/** Resolves a path correctly from site directory */
|
|
167
|
+
resolveFromSiteDir(...args) {
|
|
168
|
+
return resolve(this.requiredServerFiles.appDir, ...args);
|
|
169
|
+
}
|
|
170
|
+
/** Get the next prerender-manifest.json */
|
|
171
|
+
async getPrerenderManifest() {
|
|
172
|
+
return JSON.parse(await readFile(join(this.publishDir, "prerender-manifest.json"), "utf-8"));
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Uses various heuristics to try to find the .next dir.
|
|
176
|
+
* Works by looking for BUILD_ID, so requires the site to have been built
|
|
177
|
+
*/
|
|
178
|
+
findDotNext() {
|
|
179
|
+
for (const dir of [
|
|
180
|
+
// The publish directory
|
|
181
|
+
this.publishDir,
|
|
182
|
+
// In the root
|
|
183
|
+
resolve(DEFAULT_PUBLISH_DIR),
|
|
184
|
+
// The sibling of the publish directory
|
|
185
|
+
resolve(this.publishDir, "..", DEFAULT_PUBLISH_DIR),
|
|
186
|
+
// In the package dir
|
|
187
|
+
resolve(this.constants.PACKAGE_PATH || "", DEFAULT_PUBLISH_DIR)
|
|
188
|
+
]) {
|
|
189
|
+
if (existsSync(join(dir, "BUILD_ID"))) {
|
|
190
|
+
return dir;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get Next.js middleware config from the build output
|
|
197
|
+
*/
|
|
198
|
+
async getMiddlewareManifest() {
|
|
199
|
+
return JSON.parse(
|
|
200
|
+
await readFile(join(this.publishDir, "server/middleware-manifest.json"), "utf-8")
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
// don't make private as it is handy inside testing to override the config
|
|
204
|
+
_requiredServerFiles = null;
|
|
205
|
+
/** Get RequiredServerFiles manifest from build output **/
|
|
206
|
+
get requiredServerFiles() {
|
|
207
|
+
if (!this._requiredServerFiles) {
|
|
208
|
+
let requiredServerFilesJson = join(this.publishDir, "required-server-files.json");
|
|
209
|
+
if (!existsSync(requiredServerFilesJson)) {
|
|
210
|
+
const dotNext = this.findDotNext();
|
|
211
|
+
if (dotNext) {
|
|
212
|
+
requiredServerFilesJson = join(dotNext, "required-server-files.json");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
this._requiredServerFiles = JSON.parse(
|
|
216
|
+
readFileSync(requiredServerFilesJson, "utf-8")
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
return this._requiredServerFiles;
|
|
220
|
+
}
|
|
221
|
+
#exportDetail = null;
|
|
222
|
+
/** Get metadata when output = export */
|
|
223
|
+
get exportDetail() {
|
|
224
|
+
if (this.buildConfig.output !== "export") {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
if (!this.#exportDetail) {
|
|
228
|
+
const detailFile = join(
|
|
229
|
+
this.requiredServerFiles.appDir,
|
|
230
|
+
this.buildConfig.distDir,
|
|
231
|
+
"export-detail.json"
|
|
232
|
+
);
|
|
233
|
+
if (!existsSync(detailFile)) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
this.#exportDetail = JSON.parse(readFileSync(detailFile, "utf-8"));
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return this.#exportDetail;
|
|
242
|
+
}
|
|
243
|
+
/** Get Next Config from build output **/
|
|
244
|
+
get buildConfig() {
|
|
245
|
+
return this.requiredServerFiles.config;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Get Next.js routes manifest from the build output
|
|
249
|
+
*/
|
|
250
|
+
async getRoutesManifest() {
|
|
251
|
+
return JSON.parse(await readFile(join(this.publishDir, "routes-manifest.json"), "utf-8"));
|
|
252
|
+
}
|
|
253
|
+
#nextVersion = void 0;
|
|
254
|
+
/**
|
|
255
|
+
* Get Next.js version that was used to build the site
|
|
256
|
+
*/
|
|
257
|
+
get nextVersion() {
|
|
258
|
+
if (this.#nextVersion === void 0) {
|
|
259
|
+
try {
|
|
260
|
+
const serverHandlerRequire = createRequire(posixJoin(this.standaloneRootDir, ":internal:"));
|
|
261
|
+
const { version } = serverHandlerRequire("next/package.json");
|
|
262
|
+
this.#nextVersion = version;
|
|
263
|
+
} catch {
|
|
264
|
+
this.#nextVersion = null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return this.#nextVersion;
|
|
268
|
+
}
|
|
269
|
+
#fallbacks = null;
|
|
270
|
+
/**
|
|
271
|
+
* Get an array of localized fallback routes
|
|
272
|
+
*
|
|
273
|
+
* Example return value for non-i18n site: `['blog/[slug]']`
|
|
274
|
+
*
|
|
275
|
+
* Example return value for i18n site: `['en/blog/[slug]', 'fr/blog/[slug]']`
|
|
276
|
+
*/
|
|
277
|
+
getFallbacks(prerenderManifest) {
|
|
278
|
+
if (!this.#fallbacks) {
|
|
279
|
+
const locales = this.buildConfig.i18n?.locales ?? [""];
|
|
280
|
+
this.#fallbacks = Object.entries(prerenderManifest.dynamicRoutes).reduce(
|
|
281
|
+
(fallbacks, [route, meta]) => {
|
|
282
|
+
if (typeof meta.fallback === "string") {
|
|
283
|
+
for (const locale of locales) {
|
|
284
|
+
const localizedRoute = posixJoin(locale, route.replace(/^\/+/g, ""));
|
|
285
|
+
fallbacks.push(localizedRoute);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return fallbacks;
|
|
289
|
+
},
|
|
290
|
+
[]
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return this.#fallbacks;
|
|
294
|
+
}
|
|
295
|
+
/** Fails a build with a message and an optional error */
|
|
296
|
+
failBuild(message, error) {
|
|
297
|
+
return this.utils.build.failBuild(message, error instanceof Error ? { error } : void 0);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
14
300
|
export {
|
|
15
301
|
EDGE_HANDLER_NAME,
|
|
16
302
|
PluginContext,
|
|
@@ -5,15 +5,110 @@
|
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "../esm-chunks/chunk-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
require_out
|
|
9
|
+
} from "../esm-chunks/chunk-KGYJQ2U2.js";
|
|
10
|
+
import {
|
|
11
|
+
require_semver
|
|
12
|
+
} from "../esm-chunks/chunk-APO262HE.js";
|
|
13
|
+
import {
|
|
14
|
+
__toESM
|
|
15
|
+
} from "../esm-chunks/chunk-OEQOKJGE.js";
|
|
16
|
+
|
|
17
|
+
// src/build/verification.ts
|
|
18
|
+
var import_fast_glob = __toESM(require_out(), 1);
|
|
19
|
+
var import_semver = __toESM(require_semver(), 1);
|
|
20
|
+
import { existsSync } from "node:fs";
|
|
21
|
+
import { readFile } from "node:fs/promises";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
import { ApiRouteType, getAPIRoutesConfigs } from "./advanced-api-routes.js";
|
|
24
|
+
var SUPPORTED_NEXT_VERSIONS = ">=13.5.0";
|
|
25
|
+
var verifications = /* @__PURE__ */ new Set();
|
|
26
|
+
function verifyPublishDir(ctx) {
|
|
27
|
+
if (!existsSync(ctx.publishDir)) {
|
|
28
|
+
ctx.failBuild(
|
|
29
|
+
`Your publish directory was not found at: ${ctx.publishDir}. Please check your build settings`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (ctx.publishDir === ctx.resolveFromPackagePath("")) {
|
|
33
|
+
ctx.failBuild(
|
|
34
|
+
`Your publish directory cannot be the same as the base directory of your site. Please check your build settings`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
ctx.buildConfig;
|
|
39
|
+
} catch {
|
|
40
|
+
ctx.failBuild(
|
|
41
|
+
"Your publish directory does not contain expected Next.js build output. Please check your build settings"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (ctx.buildConfig.output === "standalone" || ctx.buildConfig.output === void 0) {
|
|
45
|
+
if (!existsSync(join(ctx.publishDir, "BUILD_ID"))) {
|
|
46
|
+
ctx.failBuild(
|
|
47
|
+
"Your publish directory does not contain expected Next.js build output. Please check your build settings"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (!existsSync(ctx.standaloneRootDir)) {
|
|
51
|
+
ctx.failBuild(
|
|
52
|
+
`Your publish directory does not contain expected Next.js build output. Please make sure you are using Next.js version (${SUPPORTED_NEXT_VERSIONS})`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (ctx.nextVersion && !(0, import_semver.satisfies)(ctx.nextVersion, SUPPORTED_NEXT_VERSIONS, { includePrerelease: true })) {
|
|
56
|
+
ctx.failBuild(
|
|
57
|
+
`@netlify/plugin-nextjs@5 requires Next.js version ${SUPPORTED_NEXT_VERSIONS}, but found ${ctx.nextVersion}. Please upgrade your project's Next.js version.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (ctx.buildConfig.output === "export") {
|
|
62
|
+
if (!ctx.exportDetail?.success) {
|
|
63
|
+
ctx.failBuild(`Your export failed to build. Please check your build settings`);
|
|
64
|
+
}
|
|
65
|
+
if (!existsSync(ctx.exportDetail?.outDirectory)) {
|
|
66
|
+
ctx.failBuild(
|
|
67
|
+
`Your export directory was not found at: ${ctx.exportDetail?.outDirectory}. Please check your build settings`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function verifyAdvancedAPIRoutes(ctx) {
|
|
73
|
+
const apiRoutesConfigs = await getAPIRoutesConfigs(ctx);
|
|
74
|
+
const unsupportedAPIRoutes = apiRoutesConfigs.filter((apiRouteConfig) => {
|
|
75
|
+
return apiRouteConfig.config.type === ApiRouteType.BACKGROUND || apiRouteConfig.config.type === ApiRouteType.SCHEDULED;
|
|
76
|
+
});
|
|
77
|
+
if (unsupportedAPIRoutes.length !== 0) {
|
|
78
|
+
ctx.failBuild(
|
|
79
|
+
`@netlify/plugin-nextjs@5 does not support advanced API routes. The following API routes should be migrated to Netlify background or scheduled functions:
|
|
80
|
+
${unsupportedAPIRoutes.map((apiRouteConfig) => ` - ${apiRouteConfig.apiRoute} (type: "${apiRouteConfig.config.type}")`).join("\n")}
|
|
81
|
+
|
|
82
|
+
Refer to https://ntl.fyi/next-scheduled-bg-function-migration as migration example.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var formDetectionRegex = /<form[^>]*?\s(netlify|data-netlify)[=>\s]/;
|
|
87
|
+
async function verifyNetlifyFormsWorkaround(ctx) {
|
|
88
|
+
const srcDir = ctx.resolveFromSiteDir("public");
|
|
89
|
+
const paths = await (0, import_fast_glob.glob)("**/*.html", {
|
|
90
|
+
cwd: srcDir,
|
|
91
|
+
dot: true
|
|
92
|
+
});
|
|
93
|
+
try {
|
|
94
|
+
for (const path of paths) {
|
|
95
|
+
const html = await readFile(join(srcDir, path), "utf-8");
|
|
96
|
+
if (formDetectionRegex.test(html)) {
|
|
97
|
+
verifications.add("netlifyFormsWorkaround");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
ctx.failBuild("Failed verifying public files", error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function verifyNetlifyForms(ctx, html) {
|
|
106
|
+
if (process.env.NETLIFY_NEXT_VERIFY_FORMS !== "0" && process.env.NETLIFY_NEXT_VERIFY_FORMS?.toUpperCase() !== "FALSE" && !verifications.has("netlifyFormsWorkaround") && formDetectionRegex.test(html)) {
|
|
107
|
+
ctx.failBuild(
|
|
108
|
+
"@netlify/plugin-nextjs@5 requires migration steps to support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example."
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
17
112
|
export {
|
|
18
113
|
verifyAdvancedAPIRoutes,
|
|
19
114
|
verifyNetlifyForms,
|
|
@@ -8,7 +8,7 @@ import "./chunk-OEQOKJGE.js";
|
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var name = "@netlify/plugin-nextjs";
|
|
11
|
-
var version = "5.10.
|
|
11
|
+
var version = "5.10.2";
|
|
12
12
|
var description = "Run Next.js seamlessly on Netlify";
|
|
13
13
|
var main = "./dist/index.js";
|
|
14
14
|
var type = "module";
|
|
@@ -56,15 +56,15 @@ var bugs = {
|
|
|
56
56
|
};
|
|
57
57
|
var homepage = "https://opennext.js.org/netlify";
|
|
58
58
|
var devDependencies = {
|
|
59
|
-
"@fastly/http-compute-js": "1.1.
|
|
60
|
-
"@netlify/blobs": "^8.1.
|
|
61
|
-
"@netlify/build": "^
|
|
62
|
-
"@netlify/edge-bundler": "^12.
|
|
63
|
-
"@netlify/edge-functions": "^2.11.
|
|
59
|
+
"@fastly/http-compute-js": "1.1.5",
|
|
60
|
+
"@netlify/blobs": "^8.1.2",
|
|
61
|
+
"@netlify/build": "^30.1.0",
|
|
62
|
+
"@netlify/edge-bundler": "^12.4.0",
|
|
63
|
+
"@netlify/edge-functions": "^2.11.1",
|
|
64
64
|
"@netlify/eslint-config-node": "^7.0.1",
|
|
65
|
-
"@netlify/functions": "^3.0.
|
|
66
|
-
"@netlify/serverless-functions-api": "^1.
|
|
67
|
-
"@netlify/zip-it-and-ship-it": "^
|
|
65
|
+
"@netlify/functions": "^3.0.4",
|
|
66
|
+
"@netlify/serverless-functions-api": "^1.36.0",
|
|
67
|
+
"@netlify/zip-it-and-ship-it": "^10.0.4",
|
|
68
68
|
"@opentelemetry/api": "^1.8.0",
|
|
69
69
|
"@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
|
|
70
70
|
"@opentelemetry/resources": "^1.24.0",
|
|
@@ -84,10 +84,11 @@ var devDependencies = {
|
|
|
84
84
|
"fs-monkey": "^1.0.6",
|
|
85
85
|
"get-port": "^7.1.0",
|
|
86
86
|
"lambda-local": "^2.2.0",
|
|
87
|
+
"lru-cache": "^10.4.3",
|
|
87
88
|
memfs: "^4.9.2",
|
|
88
89
|
"mock-require": "^3.0.3",
|
|
89
90
|
msw: "^2.0.7",
|
|
90
|
-
"netlify-cli": "^
|
|
91
|
+
"netlify-cli": "^19.1.4",
|
|
91
92
|
next: "^15.0.0-canary.28",
|
|
92
93
|
os: "^0.1.2",
|
|
93
94
|
outdent: "^0.8.0",
|
package/dist/index.js
CHANGED
|
@@ -4,26 +4,6 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
copyPrerenderedContent
|
|
9
|
-
} from "./esm-chunks/chunk-DLBTTDNJ.js";
|
|
10
|
-
import {
|
|
11
|
-
copyStaticAssets,
|
|
12
|
-
copyStaticContent,
|
|
13
|
-
copyStaticExport,
|
|
14
|
-
publishStaticDir,
|
|
15
|
-
setHeadersConfig,
|
|
16
|
-
unpublishStaticDir
|
|
17
|
-
} from "./esm-chunks/chunk-VTKZZRGT.js";
|
|
18
|
-
import {
|
|
19
|
-
clearStaleEdgeHandlers,
|
|
20
|
-
createEdgeHandlers
|
|
21
|
-
} from "./esm-chunks/chunk-3RQSTU2O.js";
|
|
22
|
-
import {
|
|
23
|
-
clearStaleServerHandlers,
|
|
24
|
-
createServerHandler
|
|
25
|
-
} from "./esm-chunks/chunk-DLVROEVU.js";
|
|
26
|
-
import "./esm-chunks/chunk-IJZEDP6B.js";
|
|
27
7
|
import {
|
|
28
8
|
wrapTracer
|
|
29
9
|
} from "./esm-chunks/chunk-5QSXBV7L.js";
|
|
@@ -31,31 +11,30 @@ import {
|
|
|
31
11
|
init_esm,
|
|
32
12
|
trace
|
|
33
13
|
} from "./esm-chunks/chunk-GNGHTHMQ.js";
|
|
34
|
-
import {
|
|
35
|
-
restoreBuildCache,
|
|
36
|
-
saveBuildCache
|
|
37
|
-
} from "./esm-chunks/chunk-72ZI2IVI.js";
|
|
38
|
-
import {
|
|
39
|
-
setImageConfig
|
|
40
|
-
} from "./esm-chunks/chunk-AMY4NOT5.js";
|
|
41
|
-
import {
|
|
42
|
-
PluginContext
|
|
43
|
-
} from "./esm-chunks/chunk-GFYWJNQR.js";
|
|
44
|
-
import {
|
|
45
|
-
verifyAdvancedAPIRoutes,
|
|
46
|
-
verifyNetlifyFormsWorkaround,
|
|
47
|
-
verifyPublishDir
|
|
48
|
-
} from "./esm-chunks/chunk-ZSVHJNNY.js";
|
|
49
|
-
import "./esm-chunks/chunk-KGYJQ2U2.js";
|
|
50
|
-
import "./esm-chunks/chunk-ZENB67PD.js";
|
|
51
|
-
import "./esm-chunks/chunk-APO262HE.js";
|
|
52
|
-
import "./esm-chunks/chunk-TYCYFZ22.js";
|
|
53
|
-
import "./esm-chunks/chunk-UYKENJEU.js";
|
|
54
14
|
import "./esm-chunks/chunk-OEQOKJGE.js";
|
|
55
15
|
|
|
56
16
|
// src/index.ts
|
|
57
17
|
init_esm();
|
|
58
18
|
import { rm } from "fs/promises";
|
|
19
|
+
import { restoreBuildCache, saveBuildCache } from "./build/cache.js";
|
|
20
|
+
import { copyPrerenderedContent } from "./build/content/prerendered.js";
|
|
21
|
+
import {
|
|
22
|
+
copyStaticAssets,
|
|
23
|
+
copyStaticContent,
|
|
24
|
+
copyStaticExport,
|
|
25
|
+
publishStaticDir,
|
|
26
|
+
setHeadersConfig,
|
|
27
|
+
unpublishStaticDir
|
|
28
|
+
} from "./build/content/static.js";
|
|
29
|
+
import { clearStaleEdgeHandlers, createEdgeHandlers } from "./build/functions/edge.js";
|
|
30
|
+
import { clearStaleServerHandlers, createServerHandler } from "./build/functions/server.js";
|
|
31
|
+
import { setImageConfig } from "./build/image-cdn.js";
|
|
32
|
+
import { PluginContext } from "./build/plugin-context.js";
|
|
33
|
+
import {
|
|
34
|
+
verifyAdvancedAPIRoutes,
|
|
35
|
+
verifyNetlifyFormsWorkaround,
|
|
36
|
+
verifyPublishDir
|
|
37
|
+
} from "./build/verification.js";
|
|
59
38
|
var tracer = wrapTracer(trace.getTracer("Next.js runtime"));
|
|
60
39
|
var onPreDev = async (options) => {
|
|
61
40
|
await tracer.withActiveSpan("onPreDev", async () => {
|
package/dist/run/config.js
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
PLUGIN_DIR,
|
|
9
|
-
RUN_CONFIG
|
|
10
|
-
} from "../esm-chunks/chunk-UYKENJEU.js";
|
|
11
7
|
import "../esm-chunks/chunk-OEQOKJGE.js";
|
|
12
8
|
|
|
13
9
|
// src/run/config.ts
|
|
14
10
|
import { existsSync } from "node:fs";
|
|
15
11
|
import { readFile } from "node:fs/promises";
|
|
16
12
|
import { join, resolve } from "node:path";
|
|
13
|
+
import { PLUGIN_DIR, RUN_CONFIG } from "./constants.js";
|
|
14
|
+
import { setInMemoryCacheMaxSizeFromNextConfig } from "./storage/storage.cjs";
|
|
17
15
|
var getRunConfig = async () => {
|
|
18
16
|
return JSON.parse(await readFile(resolve(PLUGIN_DIR, RUN_CONFIG), "utf-8"));
|
|
19
17
|
};
|
|
@@ -24,12 +22,13 @@ var setRunConfig = (config) => {
|
|
|
24
22
|
}
|
|
25
23
|
config.experimental = {
|
|
26
24
|
...config.experimental,
|
|
27
|
-
//
|
|
28
|
-
// but we still need to set it for older Next.js versions
|
|
25
|
+
// Before Next.js 14.1.0 path to the cache handler was in experimental section, see NextConfigForMultipleVersions type
|
|
29
26
|
incrementalCacheHandlerPath: cacheHandler
|
|
30
27
|
};
|
|
31
28
|
config.cacheHandler = cacheHandler;
|
|
32
|
-
|
|
29
|
+
setInMemoryCacheMaxSizeFromNextConfig(
|
|
30
|
+
config.cacheMaxMemorySize ?? config.experimental?.isrMemoryCacheSize
|
|
31
|
+
);
|
|
33
32
|
process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(config);
|
|
34
33
|
};
|
|
35
34
|
export {
|
package/dist/run/constants.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
return createRequire(import.meta.url);
|
|
5
5
|
})();
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
MODULE_DIR,
|
|
9
|
-
PLUGIN_DIR,
|
|
10
|
-
RUN_CONFIG
|
|
11
|
-
} from "../esm-chunks/chunk-UYKENJEU.js";
|
|
12
7
|
import "../esm-chunks/chunk-OEQOKJGE.js";
|
|
8
|
+
|
|
9
|
+
// src/run/constants.ts
|
|
10
|
+
import { resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
13
|
+
var PLUGIN_DIR = resolve(`${MODULE_DIR}../../..`);
|
|
14
|
+
var RUN_CONFIG = "run-config.json";
|
|
13
15
|
export {
|
|
14
16
|
MODULE_DIR,
|
|
15
17
|
PLUGIN_DIR,
|