@netlify/plugin-nextjs 4.40.0 → 4.40.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
CHANGED
|
@@ -138,7 +138,7 @@ exports.writeDevEdgeFunction = writeDevEdgeFunction;
|
|
|
138
138
|
/**
|
|
139
139
|
* Writes an edge function that routes RSC data requests to the `.rsc` route
|
|
140
140
|
*/
|
|
141
|
-
const generateRscDataEdgeManifest = async ({ prerenderManifest, appPathRoutesManifest, }) => {
|
|
141
|
+
const generateRscDataEdgeManifest = async ({ prerenderManifest, appPathRoutesManifest, packagePath = '', }) => {
|
|
142
142
|
const generator = await (0, functionsMetaData_1.getPluginVersion)();
|
|
143
143
|
if (!prerenderManifest || !appPathRoutesManifest) {
|
|
144
144
|
return [];
|
|
@@ -158,7 +158,7 @@ const generateRscDataEdgeManifest = async ({ prerenderManifest, appPathRoutesMan
|
|
|
158
158
|
if (staticAppdirRoutes.length === 0 && dynamicAppDirRoutes.length === 0) {
|
|
159
159
|
return [];
|
|
160
160
|
}
|
|
161
|
-
const edgeFunctionDir = (0, path_1.resolve)('.netlify', 'edge-functions', 'rsc-data');
|
|
161
|
+
const edgeFunctionDir = (0, path_1.resolve)(packagePath, '.netlify', 'edge-functions', 'rsc-data');
|
|
162
162
|
await (0, fs_extra_1.ensureDir)(edgeFunctionDir);
|
|
163
163
|
await copyEdgeSourceFile({ edgeFunctionDir, file: 'rsc-data.ts' });
|
|
164
164
|
return [
|
|
@@ -219,6 +219,7 @@ const writeEdgeFunctions = async ({ netlifyConfig, routesManifest, constants: {
|
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
221
|
const rscFunctions = await (0, exports.generateRscDataEdgeManifest)({
|
|
222
|
+
packagePath: PACKAGE_PATH,
|
|
222
223
|
prerenderManifest: await (0, exports.loadPrerenderManifest)(netlifyConfig),
|
|
223
224
|
appPathRoutesManifest: await (0, exports.loadAppPathRoutesManifest)(netlifyConfig),
|
|
224
225
|
});
|
|
@@ -68,8 +68,7 @@ const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mod
|
|
|
68
68
|
try {
|
|
69
69
|
await requestHandler(req, res);
|
|
70
70
|
}
|
|
71
|
-
catch
|
|
72
|
-
console.error(error);
|
|
71
|
+
catch {
|
|
73
72
|
throw new Error('Error handling request. See function logs for details.');
|
|
74
73
|
}
|
|
75
74
|
});
|
|
@@ -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.localizeDataRoute = exports.localizeRoute = exports.unlocalizeRoute = exports.joinPaths = exports.normalizeRoute = exports.netlifyApiFetch = exports.normalizePath = exports.getPrefetchResponse = exports.augmentFsModule = exports.getMultiValueHeaders = exports.getMaxAge = exports.downloadFile = void 0;
|
|
6
|
+
exports.getMatchedRoute = exports.localizeDataRoute = exports.localizeRoute = exports.unlocalizeRoute = exports.joinPaths = exports.normalizeRoute = exports.netlifyApiFetch = exports.normalizePath = exports.getPrefetchResponse = exports.augmentFsModule = exports.getMultiValueHeaders = exports.getMaxAge = exports.downloadFile = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const os_1 = require("os");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -230,3 +230,16 @@ const localizeDataRoute = (dataRoute, localizedRoute) => {
|
|
|
230
230
|
.replace(/\/index\.json$/, '.json');
|
|
231
231
|
};
|
|
232
232
|
exports.localizeDataRoute = localizeDataRoute;
|
|
233
|
+
const getMatchedRoute = (paths, routesManifest, parsedUrl, basePath, trailingSlash) => routesManifest === null || routesManifest === void 0 ? void 0 : routesManifest.find((route) => {
|
|
234
|
+
// Some internationalized routes are automatically removing the locale prefix making the path not match the route
|
|
235
|
+
// we can use the parsedURL, which has the locale included and will match
|
|
236
|
+
const base = '/';
|
|
237
|
+
return new RegExp(route.regex).test(new URL(
|
|
238
|
+
// If using basepath config, we have to use the original path to match the route
|
|
239
|
+
// This seems to only be an issue on the index page when using group routes
|
|
240
|
+
parsedUrl ||
|
|
241
|
+
(basePath && paths === (trailingSlash && !(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? `${basePath}/` : basePath)
|
|
242
|
+
? base
|
|
243
|
+
: paths), 'http://n').pathname);
|
|
244
|
+
});
|
|
245
|
+
exports.getMatchedRoute = getMatchedRoute;
|
package/lib/templates/server.js
CHANGED
|
@@ -7,6 +7,10 @@ const handlerUtils_1 = require("./handlerUtils");
|
|
|
7
7
|
// eslint-disable-next-line max-lines-per-function
|
|
8
8
|
const getNetlifyNextServer = (NextServer) => {
|
|
9
9
|
class NetlifyNextServer extends NextServer {
|
|
10
|
+
getAppRouterReactVersion() {
|
|
11
|
+
var _a;
|
|
12
|
+
return ((_a = this.nextConfig.experimental) === null || _a === void 0 ? void 0 : _a.serverActions) ? 'experimental' : 'next';
|
|
13
|
+
}
|
|
10
14
|
constructor(options, netlifyConfig) {
|
|
11
15
|
super(options);
|
|
12
16
|
this.netlifyConfig = netlifyConfig;
|
|
@@ -28,7 +32,7 @@ const getNetlifyNextServer = (NextServer) => {
|
|
|
28
32
|
// preserve the URL before Next.js mutates it for i18n
|
|
29
33
|
const { url, headers } = req;
|
|
30
34
|
// conditionally use the prebundled React module
|
|
31
|
-
this.netlifyPrebundleReact(url);
|
|
35
|
+
this.netlifyPrebundleReact(url, this.nextConfig, parsedUrl);
|
|
32
36
|
// intercept on-demand revalidation requests and handle with the Netlify API
|
|
33
37
|
if (headers['x-prerender-revalidate'] && this.netlifyConfig.revalidateToken) {
|
|
34
38
|
// handle on-demand revalidation by purging the ODB cache
|
|
@@ -52,22 +56,19 @@ const getNetlifyNextServer = (NextServer) => {
|
|
|
52
56
|
};
|
|
53
57
|
}
|
|
54
58
|
// doing what they do in https://github.com/vercel/vercel/blob/1663db7ca34d3dd99b57994f801fb30b72fbd2f3/packages/next/src/server-build.ts#L576-L580
|
|
55
|
-
netlifyPrebundleReact(path) {
|
|
56
|
-
var _a, _b
|
|
59
|
+
async netlifyPrebundleReact(path, { basePath, trailingSlash }, parsedUrl) {
|
|
60
|
+
var _a, _b;
|
|
57
61
|
const routesManifest = (_a = this.getRoutesManifest) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
58
62
|
const appPathsRoutes = (_b = this.getAppPathRoutes) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
59
63
|
const routes = routesManifest && [...routesManifest.staticRoutes, ...routesManifest.dynamicRoutes];
|
|
60
|
-
const matchedRoute =
|
|
64
|
+
const matchedRoute = await (0, handlerUtils_1.getMatchedRoute)(path, routes, parsedUrl, basePath, trailingSlash);
|
|
61
65
|
const isAppRoute = appPathsRoutes && matchedRoute ? appPathsRoutes[matchedRoute.page] : false;
|
|
62
66
|
if (isAppRoute) {
|
|
63
67
|
// app routes should use prebundled React
|
|
64
68
|
// eslint-disable-next-line no-underscore-dangle
|
|
65
|
-
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT =
|
|
66
|
-
? 'experimental'
|
|
67
|
-
: 'next';
|
|
69
|
+
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = this.getAppRouterReactVersion();
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
|
-
// pages routes should use use node_modules React
|
|
71
72
|
// eslint-disable-next-line no-underscore-dangle
|
|
72
73
|
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = '';
|
|
73
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.40.
|
|
3
|
+
"version": "4.40.1",
|
|
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.20.
|
|
40
|
+
"@netlify/build": "^29.20.6",
|
|
41
41
|
"@types/fs-extra": "^9.0.13",
|
|
42
42
|
"@types/jest": "^27.4.1",
|
|
43
43
|
"@types/merge-stream": "^1.1.2",
|