@netlify/plugin-nextjs 4.34.0 → 4.35.0
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/analysis.js
CHANGED
|
@@ -23,16 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.extractConfigFromFile = exports.validateConfigValue = void 0;
|
|
26
|
+
exports.extractConfigFromFile = exports.validateConfigValue = exports.isEdgeConfig = void 0;
|
|
27
27
|
const fs_1 = __importStar(require("fs"));
|
|
28
28
|
const pathe_1 = require("pathe");
|
|
29
|
+
const isEdgeConfig = (config) => ['experimental-edge', 'edge'].includes(config);
|
|
30
|
+
exports.isEdgeConfig = isEdgeConfig;
|
|
29
31
|
const validateConfigValue = (config, apiFilePath) => {
|
|
30
32
|
if (config.type === "experimental-scheduled" /* ApiRouteType.SCHEDULED */) {
|
|
31
33
|
if (!config.schedule) {
|
|
32
34
|
console.error(`Invalid config value in ${(0, pathe_1.relative)(process.cwd(), apiFilePath)}: schedule is required when type is "${"experimental-scheduled" /* ApiRouteType.SCHEDULED */}"`);
|
|
33
35
|
return false;
|
|
34
36
|
}
|
|
35
|
-
if (config.runtime
|
|
37
|
+
if ((0, exports.isEdgeConfig)(config.runtime)) {
|
|
36
38
|
console.error(`Invalid config value in ${(0, pathe_1.relative)(process.cwd(), apiFilePath)}: edge runtime is not supported for scheduled functions`);
|
|
37
39
|
return false;
|
|
38
40
|
}
|
|
@@ -43,7 +45,7 @@ const validateConfigValue = (config, apiFilePath) => {
|
|
|
43
45
|
console.error(`Invalid config value in ${(0, pathe_1.relative)(process.cwd(), apiFilePath)}: schedule is not allowed unless type is "${"experimental-scheduled" /* ApiRouteType.SCHEDULED */}"`);
|
|
44
46
|
return false;
|
|
45
47
|
}
|
|
46
|
-
if (config.type && config.runtime
|
|
48
|
+
if (config.type && (0, exports.isEdgeConfig)(config.runtime)) {
|
|
47
49
|
console.error(`Invalid config value in ${(0, pathe_1.relative)(process.cwd(), apiFilePath)}: edge runtime is not supported for background functions`);
|
|
48
50
|
return false;
|
|
49
51
|
}
|
package/lib/helpers/edge.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.writeEdgeFunctions = exports.getEdgeFunctionPatternForPage = exports.
|
|
6
|
+
exports.writeEdgeFunctions = exports.getEdgeFunctionPatternForPage = exports.generateRscDataEdgeManifest = exports.writeDevEdgeFunction = exports.cleanupEdgeFunctions = exports.loadPrerenderManifest = exports.loadAppPathRoutesManifest = exports.loadMiddlewareManifest = exports.isAppDirRoute = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const chalk_1 = require("chalk");
|
|
@@ -130,19 +130,19 @@ exports.writeDevEdgeFunction = writeDevEdgeFunction;
|
|
|
130
130
|
/**
|
|
131
131
|
* Writes an edge function that routes RSC data requests to the `.rsc` route
|
|
132
132
|
*/
|
|
133
|
-
const
|
|
133
|
+
const generateRscDataEdgeManifest = async ({ prerenderManifest, appPathRoutesManifest, }) => {
|
|
134
134
|
if (!prerenderManifest || !appPathRoutesManifest) {
|
|
135
135
|
return [];
|
|
136
136
|
}
|
|
137
137
|
const staticAppdirRoutes = [];
|
|
138
138
|
for (const [path, route] of Object.entries(prerenderManifest.routes)) {
|
|
139
|
-
if ((0, exports.isAppDirRoute)(route.srcRoute, appPathRoutesManifest)) {
|
|
139
|
+
if ((0, exports.isAppDirRoute)(route.srcRoute, appPathRoutesManifest) && route.dataRoute) {
|
|
140
140
|
staticAppdirRoutes.push(path, route.dataRoute);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
const dynamicAppDirRoutes = [];
|
|
144
144
|
for (const [path, route] of Object.entries(prerenderManifest.dynamicRoutes)) {
|
|
145
|
-
if ((0, exports.isAppDirRoute)(path, appPathRoutesManifest)) {
|
|
145
|
+
if ((0, exports.isAppDirRoute)(path, appPathRoutesManifest) && route.dataRouteRegex) {
|
|
146
146
|
dynamicAppDirRoutes.push(route.routeRegex, route.dataRouteRegex);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -165,7 +165,7 @@ const writeRscDataEdgeFunction = async ({ prerenderManifest, appPathRoutesManife
|
|
|
165
165
|
})),
|
|
166
166
|
];
|
|
167
167
|
};
|
|
168
|
-
exports.
|
|
168
|
+
exports.generateRscDataEdgeManifest = generateRscDataEdgeManifest;
|
|
169
169
|
const getEdgeFunctionPatternForPage = ({ edgeFunctionDefinition, pageRegexMap, appPathRoutesManifest, }) => {
|
|
170
170
|
// We don't just use the matcher from the edge function definition, because it doesn't handle trailing slashes
|
|
171
171
|
var _a, _b;
|
|
@@ -206,7 +206,7 @@ const writeEdgeFunctions = async ({ netlifyConfig, routesManifest, }) => {
|
|
|
206
206
|
console.log('Environment variable NEXT_DISABLE_NETLIFY_EDGE has been set, skipping Netlify Edge Function creation.');
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
const rscFunctions = await (0, exports.
|
|
209
|
+
const rscFunctions = await (0, exports.generateRscDataEdgeManifest)({
|
|
210
210
|
prerenderManifest: await (0, exports.loadPrerenderManifest)(netlifyConfig),
|
|
211
211
|
appPathRoutesManifest: await (0, exports.loadAppPathRoutesManifest)(netlifyConfig),
|
|
212
212
|
});
|
package/lib/helpers/functions.js
CHANGED
|
@@ -25,7 +25,7 @@ const generateFunctions = async ({ FUNCTIONS_SRC = constants_1.DEFAULT_FUNCTIONS
|
|
|
25
25
|
const publishDir = (0, pathe_1.relative)(functionDir, publish);
|
|
26
26
|
for (const { route, config, compiled } of apiRoutes) {
|
|
27
27
|
// Don't write a lambda if the runtime is edge
|
|
28
|
-
if (config.runtime
|
|
28
|
+
if ((0, analysis_1.isEdgeConfig)(config.runtime)) {
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
31
|
const apiHandlerSource = await (0, getApiHandler_1.getApiHandler)({
|
|
@@ -91,7 +91,7 @@ const augmentFsModule = ({ promises, staticManifest, pageRoot, getBase, }) => {
|
|
|
91
91
|
// Grab the real fs.promises.readFile...
|
|
92
92
|
const readfileOrig = promises.readFile;
|
|
93
93
|
const statsOrig = promises.stat;
|
|
94
|
-
// ...then
|
|
94
|
+
// ...then monkey-patch it to see if it's requesting a CDN file
|
|
95
95
|
promises.readFile = (async (file, options) => {
|
|
96
96
|
const baseUrl = getBase();
|
|
97
97
|
// We only care about page files
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.35.0",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@delucis/if-env": "^1.1.2",
|
|
40
|
-
"@netlify/build": "^29.9.
|
|
40
|
+
"@netlify/build": "^29.9.2",
|
|
41
41
|
"@types/fs-extra": "^9.0.13",
|
|
42
42
|
"@types/jest": "^27.4.1",
|
|
43
43
|
"@types/merge-stream": "^1.1.2",
|
|
@@ -44,7 +44,7 @@ export const getRscDataRouter = ({ routes: staticRoutes, dynamicRoutes }: Preren
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
const dynamicRouteMatcher = Object.values(dynamicRoutes)
|
|
47
|
-
.filter(({ dataRoute }) => dataRoute
|
|
47
|
+
.filter(({ dataRoute }) => dataRoute?.endsWith('.rsc'))
|
|
48
48
|
.map(({ routeRegex }) => new RegExp(routeRegex))
|
|
49
49
|
|
|
50
50
|
const matchesDynamicRscDataRoute = (pathname: string) => {
|