@vercel/next 2.9.1-canary.0 → 3.0.1-canary.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/dist/edge-function-source/constants.js +3 -17
- package/dist/edge-function-source/get-edge-function-source.js +2 -2
- package/dist/edge-function-source/get-edge-function.js +4 -6
- package/dist/index.js +49611 -6
- package/dist/server-build.js +23 -13
- package/dist/sourcemapped.js +1 -1
- package/dist/utils.js +77 -57
- package/package.json +4 -4
@@ -1,23 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.EDGE_FUNCTION_SIZE_LIMIT = void 0;
|
4
4
|
const KIB = 1024;
|
5
5
|
const MIB = 1024 * KIB;
|
6
6
|
/**
|
7
|
-
* The
|
8
|
-
* See https://github.com/cloudflare/wrangler/blob/8907b12add3d70ee21ac597b69cd66f6807571f4/src/wranglerjs/output.rs#L44
|
7
|
+
* The maximum size of a *compressed* edge function.
|
9
8
|
*/
|
10
|
-
|
11
|
-
/**
|
12
|
-
* This safety buffer must cover the size of our whole runtime layer compressed
|
13
|
-
* plus some extra space to allow it to grow in the future. At the time of
|
14
|
-
* writing this comment the compressed size size is ~7KiB so 20KiB should
|
15
|
-
* be more than enough.
|
16
|
-
*/
|
17
|
-
const EDGE_FUNCTION_SCRIPT_SIZE_BUFFER = 20 * KIB;
|
18
|
-
/**
|
19
|
-
* The max size we allow for compressed user code is the compressed script
|
20
|
-
* limit minus the compressed safety buffer. We must check this limit after
|
21
|
-
* compressing the user code.
|
22
|
-
*/
|
23
|
-
exports.EDGE_FUNCTION_USER_SCRIPT_SIZE_LIMIT = EDGE_FUNCTION_SCRIPT_SIZE_LIMIT - EDGE_FUNCTION_SCRIPT_SIZE_BUFFER;
|
9
|
+
exports.EDGE_FUNCTION_SIZE_LIMIT = MIB;
|
@@ -66,7 +66,7 @@ function getWasmImportStatements(wasm = []) {
|
|
66
66
|
}
|
67
67
|
async function validateScript(content) {
|
68
68
|
const gzipped = await gzip(content);
|
69
|
-
if (gzipped.length > constants_1.
|
70
|
-
throw new Error(`Exceeds maximum edge function script size: ${(0, pretty_bytes_1.default)(gzipped.length)} / ${(0, pretty_bytes_1.default)(constants_1.
|
69
|
+
if (gzipped.length > constants_1.EDGE_FUNCTION_SIZE_LIMIT) {
|
70
|
+
throw new Error(`Exceeds maximum edge function script size: ${(0, pretty_bytes_1.default)(gzipped.length)} / ${(0, pretty_bytes_1.default)(constants_1.EDGE_FUNCTION_SIZE_LIMIT)}`);
|
71
71
|
}
|
72
72
|
}
|
@@ -10,27 +10,25 @@ const to_plain_headers_1 = require("./to-plain-headers");
|
|
10
10
|
* to avoid recomputing them for each function invocation.
|
11
11
|
*/
|
12
12
|
function getNextjsEdgeFunction(params) {
|
13
|
-
var _a;
|
14
13
|
const staticRoutes = params.staticRoutes.map(route => ({
|
15
14
|
regexp: new RegExp(route.namedRegex),
|
16
15
|
page: route.page,
|
17
16
|
}));
|
18
|
-
const dynamicRoutes =
|
17
|
+
const dynamicRoutes = params.dynamicRoutes?.map(route => ({
|
19
18
|
regexp: new RegExp(route.namedRegex),
|
20
19
|
page: route.page,
|
21
|
-
}))
|
20
|
+
})) || [];
|
22
21
|
return async function edgeFunction(request, context) {
|
23
|
-
var _a, _b;
|
24
22
|
let pathname = new URL(request.url).pathname;
|
25
23
|
let pageMatch = {};
|
26
24
|
// Remove the basePath from the URL
|
27
|
-
if (
|
25
|
+
if (params.nextConfig?.basePath) {
|
28
26
|
if (pathname.startsWith(params.nextConfig.basePath)) {
|
29
27
|
pathname = pathname.replace(params.nextConfig.basePath, '') || '/';
|
30
28
|
}
|
31
29
|
}
|
32
30
|
// Remove the locale from the URL
|
33
|
-
if (
|
31
|
+
if (params.nextConfig?.i18n) {
|
34
32
|
for (const locale of params.nextConfig.i18n.locales) {
|
35
33
|
const regexp = new RegExp(`^/${locale}($|/)`, 'i');
|
36
34
|
if (pathname.match(regexp)) {
|