@netlify/plugin-nextjs 4.9.2 → 4.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.
- package/lib/helpers/edge.js +14 -9
- package/lib/index.js +9 -0
- package/package.json +3 -3
package/lib/helpers/edge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateConfig = exports.writeEdgeFunctions = void 0;
|
|
3
|
+
exports.updateConfig = exports.writeEdgeFunctions = exports.loadMiddlewareManifest = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -11,6 +11,7 @@ const loadMiddlewareManifest = (netlifyConfig) => {
|
|
|
11
11
|
}
|
|
12
12
|
return (0, fs_extra_1.readJson)(middlewarePath);
|
|
13
13
|
};
|
|
14
|
+
exports.loadMiddlewareManifest = loadMiddlewareManifest;
|
|
14
15
|
/**
|
|
15
16
|
* Convert the Next middleware name into a valid Edge Function name
|
|
16
17
|
*/
|
|
@@ -69,7 +70,7 @@ const writeEdgeFunction = async ({ edgeFunctionDefinition, edgeFunctionRoot, net
|
|
|
69
70
|
* Writes Edge Functions for the Next middleware
|
|
70
71
|
*/
|
|
71
72
|
const writeEdgeFunctions = async (netlifyConfig) => {
|
|
72
|
-
const middlewareManifest = await loadMiddlewareManifest(netlifyConfig);
|
|
73
|
+
const middlewareManifest = await (0, exports.loadMiddlewareManifest)(netlifyConfig);
|
|
73
74
|
if (!middlewareManifest) {
|
|
74
75
|
console.error("Couldn't find the middleware manifest");
|
|
75
76
|
return;
|
|
@@ -94,13 +95,17 @@ const writeEdgeFunctions = async (netlifyConfig) => {
|
|
|
94
95
|
});
|
|
95
96
|
manifest.functions.push(functionDefinition);
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
// Older versions of the manifest format don't have the functions field
|
|
99
|
+
// No, the version field was not incremented
|
|
100
|
+
if (typeof middlewareManifest.functions === 'object') {
|
|
101
|
+
for (const edgeFunctionDefinition of Object.values(middlewareManifest.functions)) {
|
|
102
|
+
const functionDefinition = await writeEdgeFunction({
|
|
103
|
+
edgeFunctionDefinition,
|
|
104
|
+
edgeFunctionRoot,
|
|
105
|
+
netlifyConfig,
|
|
106
|
+
});
|
|
107
|
+
manifest.functions.push(functionDefinition);
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
await (0, fs_extra_1.writeJson)((0, path_1.join)(edgeFunctionRoot, 'manifest.json'), manifest);
|
|
106
111
|
};
|
package/lib/index.js
CHANGED
|
@@ -34,6 +34,7 @@ const plugin = {
|
|
|
34
34
|
netlifyConfig.build.environment.NEXT_PRIVATE_TARGET = 'server';
|
|
35
35
|
},
|
|
36
36
|
async onBuild({ constants, netlifyConfig, utils: { build: { failBuild }, }, }) {
|
|
37
|
+
var _a;
|
|
37
38
|
if ((0, utils_1.shouldSkip)()) {
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
@@ -93,6 +94,14 @@ const plugin = {
|
|
|
93
94
|
await (0, edge_1.writeEdgeFunctions)(netlifyConfig);
|
|
94
95
|
await (0, edge_1.updateConfig)(publish);
|
|
95
96
|
}
|
|
97
|
+
const middlewareManifest = await (0, edge_1.loadMiddlewareManifest)(netlifyConfig);
|
|
98
|
+
if (!process.env.NEXT_USE_NETLIFY_EDGE && ((_a = middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.sortedMiddleware) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
99
|
+
console.log((0, chalk_1.yellowBright)((0, outdent_1.outdent) `
|
|
100
|
+
You are using Next.js Middleware without Netlify Edge Functions.
|
|
101
|
+
This will soon be deprecated because it negatively affects performance and will disable ISR and static rendering.
|
|
102
|
+
To get the best performance and use Netlify Edge Functions, set the env var ${(0, chalk_1.bold) `NEXT_USE_NETLIFY_EDGE=true`}.
|
|
103
|
+
`));
|
|
104
|
+
}
|
|
96
105
|
},
|
|
97
106
|
async onPostBuild({ netlifyConfig: { build: { publish }, redirects, headers, }, utils: { status, cache, functions, build: { failBuild }, }, constants: { FUNCTIONS_DIST }, }) {
|
|
98
107
|
await (0, cache_1.saveCache)({ cache, publish });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@delucis/if-env": "^1.1.2",
|
|
31
|
-
"@netlify/build": "^27.
|
|
31
|
+
"@netlify/build": "^27.3.1",
|
|
32
32
|
"@types/fs-extra": "^9.0.13",
|
|
33
33
|
"@types/jest": "^27.4.1",
|
|
34
34
|
"@types/node": "^17.0.25",
|
|
35
|
-
"next": "^12.
|
|
35
|
+
"next": "^12.2.0",
|
|
36
36
|
"npm-run-all": "^4.1.5",
|
|
37
37
|
"typescript": "^4.6.3"
|
|
38
38
|
},
|