@netlify/plugin-nextjs 4.29.2 → 4.29.3
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/edge.js +15 -18
- package/lib/helpers/files.js +7 -5
- package/lib/helpers/functions.js +4 -1
- package/lib/templates/ipx.js +1 -1
- package/package.json +2 -2
- package/src/templates/edge/next-dev.js +11 -0
package/lib/helpers/edge.js
CHANGED
|
@@ -35,27 +35,20 @@ import {
|
|
|
35
35
|
// Deno defines "window", but naughty libraries think this means it's a browser
|
|
36
36
|
delete globalThis.window
|
|
37
37
|
globalThis.process = { env: {...Deno.env.toObject(), NEXT_RUNTIME: 'edge', 'NEXT_PRIVATE_MINIMAL_MODE': '1' } }
|
|
38
|
-
// Next uses "self" as a function-scoped global-like object
|
|
39
|
-
const self = {}
|
|
40
38
|
let _ENTRIES = {}
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.map(([, value]) => value);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
40
|
+
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
|
|
41
|
+
if(!('getAll' in Headers.prototype)) {
|
|
42
|
+
Headers.prototype.getAll = function getAll(name) {
|
|
43
|
+
name = name.toLowerCase();
|
|
44
|
+
if (name !== "set-cookie") {
|
|
45
|
+
throw new Error("Headers.getAll is only supported for Set-Cookie");
|
|
46
|
+
}
|
|
47
|
+
return [...this.entries()]
|
|
48
|
+
.filter(([key]) => key === name)
|
|
49
|
+
.map(([, value]) => value);
|
|
50
|
+
};
|
|
56
51
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
52
|
// Next uses blob: urls to refer to local assets, so we need to intercept these
|
|
60
53
|
const _fetch = globalThis.fetch
|
|
61
54
|
const fetch = async (url, init) => {
|
|
@@ -73,6 +66,10 @@ const fetch = async (url, init) => {
|
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
68
|
|
|
69
|
+
// Next edge runtime uses "self" as a function-scoped global-like object, but some of the older polyfills expect it to equal globalThis
|
|
70
|
+
// See https://nextjs.org/docs/basic-features/supported-browsers-features#polyfills
|
|
71
|
+
const self = { ...globalThis, fetch }
|
|
72
|
+
|
|
76
73
|
`;
|
|
77
74
|
// Slightly different spacing in different versions!
|
|
78
75
|
const IMPORT_UNSUPPORTED = [
|
package/lib/helpers/files.js
CHANGED
|
@@ -274,11 +274,13 @@ const getServerFile = (root, includeBase = true) => {
|
|
|
274
274
|
/**
|
|
275
275
|
* Find the source file for a given page route
|
|
276
276
|
*/
|
|
277
|
-
const getSourceFileForPage = (page,
|
|
278
|
-
for (const
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
const getSourceFileForPage = (page, roots) => {
|
|
278
|
+
for (const root of roots) {
|
|
279
|
+
for (const extension of SOURCE_FILE_EXTENSIONS) {
|
|
280
|
+
const file = (0, pathe_1.join)(root, `${page}.${extension}`);
|
|
281
|
+
if ((0, fs_extra_1.existsSync)(file)) {
|
|
282
|
+
return file;
|
|
283
|
+
}
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
286
|
console.log('Could not find source file for page', page);
|
package/lib/helpers/functions.js
CHANGED
|
@@ -123,9 +123,12 @@ exports.setupImageFunction = setupImageFunction;
|
|
|
123
123
|
const getApiRouteConfigs = async (publish, baseDir) => {
|
|
124
124
|
const pages = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(publish, 'server', 'pages-manifest.json'));
|
|
125
125
|
const apiRoutes = Object.keys(pages).filter((page) => page.startsWith('/api/'));
|
|
126
|
+
// two possible places
|
|
127
|
+
// Ref: https://nextjs.org/docs/advanced-features/src-directory
|
|
126
128
|
const pagesDir = (0, pathe_1.join)(baseDir, 'pages');
|
|
129
|
+
const srcPagesDir = (0, pathe_1.join)(baseDir, 'src', 'pages');
|
|
127
130
|
return await Promise.all(apiRoutes.map(async (apiRoute) => {
|
|
128
|
-
const filePath = (0, files_1.getSourceFileForPage)(apiRoute, pagesDir);
|
|
131
|
+
const filePath = (0, files_1.getSourceFileForPage)(apiRoute, [pagesDir, srcPagesDir]);
|
|
129
132
|
return { route: apiRoute, config: await (0, analysis_1.extractConfigFromFile)(filePath), compiled: pages[apiRoute] };
|
|
130
133
|
}));
|
|
131
134
|
};
|
package/lib/templates/ipx.js
CHANGED
|
@@ -10,4 +10,4 @@ exports.handler = (0, ipx_1.createIPXHandler)({
|
|
|
10
10
|
remotePatterns: imageconfig_json_1.remotePatterns,
|
|
11
11
|
responseHeaders: imageconfig_json_1.responseHeaders,
|
|
12
12
|
});
|
|
13
|
-
/* eslint-enable
|
|
13
|
+
/* eslint-enable import/no-unresolved, @typescript-eslint/ban-ts-comment */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.3",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@delucis/if-env": "^1.1.2",
|
|
39
|
-
"@netlify/build": "^28.
|
|
39
|
+
"@netlify/build": "^28.4.5",
|
|
40
40
|
"@types/fs-extra": "^9.0.13",
|
|
41
41
|
"@types/jest": "^27.4.1",
|
|
42
42
|
"@types/merge-stream": "^1.1.2",
|
|
@@ -6,6 +6,17 @@ import { buildResponse } from '../edge-shared/utils.ts'
|
|
|
6
6
|
globalThis.NFRequestContextMap ||= new Map()
|
|
7
7
|
globalThis.__dirname = fromFileUrl(new URL('./', import.meta.url)).slice(0, -1)
|
|
8
8
|
|
|
9
|
+
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
|
|
10
|
+
if (!('getAll' in Headers.prototype)) {
|
|
11
|
+
Headers.prototype.getAll = function getAll(name) {
|
|
12
|
+
name = name.toLowerCase()
|
|
13
|
+
if (name !== 'set-cookie') {
|
|
14
|
+
throw new Error('Headers.getAll is only supported for Set-Cookie')
|
|
15
|
+
}
|
|
16
|
+
return [...this.entries()].filter(([key]) => key === name).map(([, value]) => value)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
// Check if a file exists, given a relative path
|
|
10
21
|
const exists = async (relativePath) => {
|
|
11
22
|
const path = fromFileUrl(new URL(relativePath, import.meta.url))
|