@vercel/next 3.0.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.
@@ -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
|
}
|
package/dist/index.js
CHANGED
@@ -44725,27 +44725,13 @@ exports.default = createServerlessConfig;
|
|
44725
44725
|
"use strict";
|
44726
44726
|
|
44727
44727
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
44728
|
-
exports.
|
44728
|
+
exports.EDGE_FUNCTION_SIZE_LIMIT = void 0;
|
44729
44729
|
const KIB = 1024;
|
44730
44730
|
const MIB = 1024 * KIB;
|
44731
44731
|
/**
|
44732
|
-
* The
|
44733
|
-
* See https://github.com/cloudflare/wrangler/blob/8907b12add3d70ee21ac597b69cd66f6807571f4/src/wranglerjs/output.rs#L44
|
44732
|
+
* The maximum size of a *compressed* edge function.
|
44734
44733
|
*/
|
44735
|
-
|
44736
|
-
/**
|
44737
|
-
* This safety buffer must cover the size of our whole runtime layer compressed
|
44738
|
-
* plus some extra space to allow it to grow in the future. At the time of
|
44739
|
-
* writing this comment the compressed size size is ~7KiB so 20KiB should
|
44740
|
-
* be more than enough.
|
44741
|
-
*/
|
44742
|
-
const EDGE_FUNCTION_SCRIPT_SIZE_BUFFER = 20 * KIB;
|
44743
|
-
/**
|
44744
|
-
* The max size we allow for compressed user code is the compressed script
|
44745
|
-
* limit minus the compressed safety buffer. We must check this limit after
|
44746
|
-
* compressing the user code.
|
44747
|
-
*/
|
44748
|
-
exports.EDGE_FUNCTION_USER_SCRIPT_SIZE_LIMIT = EDGE_FUNCTION_SCRIPT_SIZE_LIMIT - EDGE_FUNCTION_SCRIPT_SIZE_BUFFER;
|
44734
|
+
exports.EDGE_FUNCTION_SIZE_LIMIT = MIB;
|
44749
44735
|
|
44750
44736
|
|
44751
44737
|
/***/ }),
|
@@ -44822,8 +44808,8 @@ function getWasmImportStatements(wasm = []) {
|
|
44822
44808
|
}
|
44823
44809
|
async function validateScript(content) {
|
44824
44810
|
const gzipped = await gzip(content);
|
44825
|
-
if (gzipped.length > constants_1.
|
44826
|
-
throw new Error(`Exceeds maximum edge function script size: ${(0, pretty_bytes_1.default)(gzipped.length)} / ${(0, pretty_bytes_1.default)(constants_1.
|
44811
|
+
if (gzipped.length > constants_1.EDGE_FUNCTION_SIZE_LIMIT) {
|
44812
|
+
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)}`);
|
44827
44813
|
}
|
44828
44814
|
}
|
44829
44815
|
|
@@ -44857,6 +44843,7 @@ const create_serverless_config_1 = __importDefault(__webpack_require__(9892));
|
|
44857
44843
|
const legacy_versions_1 = __importDefault(__webpack_require__(1207));
|
44858
44844
|
const server_build_1 = __webpack_require__(5840);
|
44859
44845
|
const utils_1 = __webpack_require__(4411);
|
44846
|
+
const assert_1 = __importDefault(__webpack_require__(2357));
|
44860
44847
|
exports.version = 2;
|
44861
44848
|
exports.htmlContentType = 'text/html; charset=utf-8';
|
44862
44849
|
const SERVER_BUILD_MINIMUM_NEXT_VERSION = 'v10.0.9-canary.4';
|
@@ -45532,7 +45519,11 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
45532
45519
|
nextFiles['next.config.js'] = filesAfterBuild['next.config.js'];
|
45533
45520
|
}
|
45534
45521
|
const pagesDir = path_1.default.join(entryPath, outputDirectory, 'server', 'static', buildId, 'pages');
|
45535
|
-
const pages = await (
|
45522
|
+
const pages = await getServerlessPages({
|
45523
|
+
pagesDir,
|
45524
|
+
entryPath,
|
45525
|
+
outputDirectory,
|
45526
|
+
});
|
45536
45527
|
const launcherPath = path_1.default.join(__dirname, 'legacy-launcher.js');
|
45537
45528
|
const launcherData = await (0, fs_extra_1.readFile)(launcherPath, 'utf8');
|
45538
45529
|
await Promise.all(Object.keys(pages).map(async (page) => {
|
@@ -45578,7 +45569,11 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
45578
45569
|
else {
|
45579
45570
|
(0, build_utils_1.debug)('Preparing serverless function files...');
|
45580
45571
|
const pagesDir = path_1.default.join(entryPath, outputDirectory, isServerMode ? 'server' : 'serverless', 'pages');
|
45581
|
-
const pages = await (
|
45572
|
+
const pages = await getServerlessPages({
|
45573
|
+
pagesDir,
|
45574
|
+
entryPath,
|
45575
|
+
outputDirectory,
|
45576
|
+
});
|
45582
45577
|
const isApiPage = (page) => page
|
45583
45578
|
.replace(/\\/g, '/')
|
45584
45579
|
.match(/(serverless|server)\/pages\/api(\/|\.js$)/);
|
@@ -46637,6 +46632,23 @@ const prepareCache = async ({ workPath, repoRootPath, entrypoint, config = {}, }
|
|
46637
46632
|
return cache;
|
46638
46633
|
};
|
46639
46634
|
exports.prepareCache = prepareCache;
|
46635
|
+
async function getServerlessPages(params) {
|
46636
|
+
const [pages, middlewareManifest] = await Promise.all([
|
46637
|
+
(0, build_utils_1.glob)('**/!(_middleware).js', params.pagesDir),
|
46638
|
+
(0, utils_1.getMiddlewareManifest)(params.entryPath, params.outputDirectory),
|
46639
|
+
]);
|
46640
|
+
// Edge Functions do not consider as Serverless Functions
|
46641
|
+
for (const edgeFunctionFile of Object.keys(middlewareManifest?.functions ?? {})) {
|
46642
|
+
// `getStaticProps` are expecting `Prerender` output which is a Serverless function
|
46643
|
+
// and not an Edge Function. Therefore we only remove API endpoints for now, as they
|
46644
|
+
// don't have `getStaticProps`.
|
46645
|
+
//
|
46646
|
+
// Context: https://github.com/vercel/vercel/pull/7905#discussion_r890213165
|
46647
|
+
(0, assert_1.default)(edgeFunctionFile.startsWith('/api/'), `Only API endpoints are currently supported for Edge endpoints.`);
|
46648
|
+
delete pages[edgeFunctionFile.slice(1) + '.js'];
|
46649
|
+
}
|
46650
|
+
return pages;
|
46651
|
+
}
|
46640
46652
|
|
46641
46653
|
|
46642
46654
|
/***/ }),
|
@@ -47920,7 +47932,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47920
47932
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
47921
47933
|
};
|
47922
47934
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
47923
|
-
exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = void 0;
|
47935
|
+
exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = void 0;
|
47924
47936
|
const build_utils_1 = __webpack_require__(3445);
|
47925
47937
|
const async_sema_1 = __webpack_require__(7916);
|
47926
47938
|
const buffer_crc32_1 = __importDefault(__webpack_require__(360));
|
@@ -49234,25 +49246,41 @@ async function getPrivateOutputs(dir, entries) {
|
|
49234
49246
|
exports.getPrivateOutputs = getPrivateOutputs;
|
49235
49247
|
async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, isCorrectMiddlewareOrder, }) {
|
49236
49248
|
const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
|
49237
|
-
|
49238
|
-
|
49239
|
-
|
49249
|
+
const sortedFunctions = [
|
49250
|
+
...(!middlewareManifest
|
49251
|
+
? []
|
49252
|
+
: middlewareManifest.sortedMiddleware.map(key => ({
|
49253
|
+
key,
|
49254
|
+
edgeFunction: middlewareManifest?.middleware[key],
|
49255
|
+
type: 'middleware',
|
49256
|
+
}))),
|
49257
|
+
...Object.entries(middlewareManifest?.functions ?? {}).map(([key, edgeFunction]) => {
|
49258
|
+
return {
|
49259
|
+
key,
|
49260
|
+
edgeFunction,
|
49261
|
+
type: 'function',
|
49262
|
+
};
|
49263
|
+
}),
|
49264
|
+
];
|
49265
|
+
if (middlewareManifest && sortedFunctions.length > 0) {
|
49266
|
+
const workerConfigs = await Promise.all(sortedFunctions.map(async ({ key, edgeFunction, type }) => {
|
49240
49267
|
try {
|
49241
|
-
const wrappedModuleSource = await (0, get_edge_function_source_1.getNextjsEdgeFunctionSource)(
|
49242
|
-
name:
|
49268
|
+
const wrappedModuleSource = await (0, get_edge_function_source_1.getNextjsEdgeFunctionSource)(edgeFunction.files, {
|
49269
|
+
name: edgeFunction.name,
|
49243
49270
|
staticRoutes: routesManifest.staticRoutes,
|
49244
49271
|
dynamicRoutes: routesManifest.dynamicRoutes.filter(r => !('isMiddleware' in r)),
|
49245
49272
|
nextConfig: {
|
49246
49273
|
basePath: routesManifest.basePath,
|
49247
49274
|
i18n: routesManifest.i18n,
|
49248
49275
|
},
|
49249
|
-
}, path_1.default.resolve(entryPath, outputDirectory),
|
49276
|
+
}, path_1.default.resolve(entryPath, outputDirectory), edgeFunction.wasm);
|
49250
49277
|
return {
|
49251
|
-
|
49278
|
+
type,
|
49279
|
+
page: edgeFunction.page,
|
49252
49280
|
edgeFunction: (() => {
|
49253
49281
|
const { source, map } = wrappedModuleSource.sourceAndMap();
|
49254
49282
|
const transformedMap = (0, sourcemapped_1.stringifySourceMap)(transformSourceMap(map));
|
49255
|
-
const wasmFiles = (
|
49283
|
+
const wasmFiles = (edgeFunction.wasm ?? []).reduce((acc, { filePath, name }) => {
|
49256
49284
|
const fullFilePath = path_1.default.join(entryPath, outputDirectory, filePath);
|
49257
49285
|
acc[`wasm/${name}.wasm`] = new build_utils_1.FileFsRef({
|
49258
49286
|
mode: 0o644,
|
@@ -49263,7 +49291,7 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
49263
49291
|
}, {});
|
49264
49292
|
return new build_utils_1.EdgeFunction({
|
49265
49293
|
deploymentTarget: 'v8-worker',
|
49266
|
-
name:
|
49294
|
+
name: edgeFunction.name,
|
49267
49295
|
files: {
|
49268
49296
|
'index.js': new build_utils_1.FileBlob({
|
49269
49297
|
data: source,
|
@@ -49280,10 +49308,10 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
49280
49308
|
...wasmFiles,
|
49281
49309
|
},
|
49282
49310
|
entrypoint: 'index.js',
|
49283
|
-
envVarsInUse:
|
49311
|
+
envVarsInUse: edgeFunction.env,
|
49284
49312
|
});
|
49285
49313
|
})(),
|
49286
|
-
routeSrc: getRouteSrc(
|
49314
|
+
routeSrc: getRouteSrc(edgeFunction, routesManifest),
|
49287
49315
|
};
|
49288
49316
|
}
|
49289
49317
|
catch (e) {
|
@@ -49298,15 +49326,21 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
49298
49326
|
};
|
49299
49327
|
for (const worker of workerConfigs.values()) {
|
49300
49328
|
const edgeFile = worker.edgeFunction.name;
|
49301
|
-
|
49302
|
-
|
49329
|
+
const shortPath = edgeFile.replace(/^pages\//, '');
|
49330
|
+
worker.edgeFunction.name = shortPath;
|
49331
|
+
source.edgeFunctions[shortPath] = worker.edgeFunction;
|
49303
49332
|
const route = {
|
49304
49333
|
continue: true,
|
49305
|
-
middlewarePath: edgeFile,
|
49306
49334
|
src: worker.routeSrc,
|
49307
49335
|
};
|
49308
|
-
if (
|
49309
|
-
route.
|
49336
|
+
if (worker.type === 'function') {
|
49337
|
+
route.dest = shortPath;
|
49338
|
+
}
|
49339
|
+
else {
|
49340
|
+
route.middlewarePath = shortPath;
|
49341
|
+
if (isCorrectMiddlewareOrder) {
|
49342
|
+
route.override = true;
|
49343
|
+
}
|
49310
49344
|
}
|
49311
49345
|
if (routesManifest.version > 3 && isDynamicRoute(worker.page)) {
|
49312
49346
|
source.dynamicRouteMap.set(worker.page, route);
|
@@ -49340,6 +49374,7 @@ async function getMiddlewareManifest(entryPath, outputDirectory) {
|
|
49340
49374
|
}
|
49341
49375
|
return fs_extra_1.default.readJSON(middlewareManifestPath);
|
49342
49376
|
}
|
49377
|
+
exports.getMiddlewareManifest = getMiddlewareManifest;
|
49343
49378
|
/**
|
49344
49379
|
* For an object containing middleware info and a routes manifest this will
|
49345
49380
|
* generate a string with the route that will activate the middleware on
|
package/dist/utils.js
CHANGED
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
23
|
};
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
-
exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = void 0;
|
25
|
+
exports.getMiddlewareManifest = exports.getMiddlewareBundle = exports.getSourceFilePathFromPage = exports.isDynamicRoute = exports.normalizePage = exports.getNextConfig = exports.normalizePackageJson = exports.validateEntrypoint = exports.excludeFiles = exports.getPrivateOutputs = exports.updateRouteSrc = exports.getNextServerPath = exports.normalizeIndexOutput = exports.getStaticFiles = exports.onPrerenderRoute = exports.onPrerenderRouteInitial = exports.detectLambdaLimitExceeding = exports.outputFunctionFileSizeInfo = exports.getPageLambdaGroups = exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = exports.addLocaleOrDefault = exports.normalizeLocalePath = exports.getPrerenderManifest = exports.getRequiredServerFilesManifest = exports.getExportStatus = exports.getExportIntent = exports.createLambdaFromPseudoLayers = exports.createPseudoLayer = exports.ExperimentalTraceVersion = exports.collectTracedFiles = exports.getFilesMapFromReasons = exports.filterStaticPages = exports.getImagesManifest = exports.localizeDynamicRoutes = exports.getDynamicRoutes = exports.getRoutesManifest = void 0;
|
26
26
|
const build_utils_1 = require("@vercel/build-utils");
|
27
27
|
const async_sema_1 = require("async-sema");
|
28
28
|
const buffer_crc32_1 = __importDefault(require("buffer-crc32"));
|
@@ -1336,25 +1336,41 @@ async function getPrivateOutputs(dir, entries) {
|
|
1336
1336
|
exports.getPrivateOutputs = getPrivateOutputs;
|
1337
1337
|
async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, isCorrectMiddlewareOrder, }) {
|
1338
1338
|
const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1339
|
+
const sortedFunctions = [
|
1340
|
+
...(!middlewareManifest
|
1341
|
+
? []
|
1342
|
+
: middlewareManifest.sortedMiddleware.map(key => ({
|
1343
|
+
key,
|
1344
|
+
edgeFunction: middlewareManifest?.middleware[key],
|
1345
|
+
type: 'middleware',
|
1346
|
+
}))),
|
1347
|
+
...Object.entries(middlewareManifest?.functions ?? {}).map(([key, edgeFunction]) => {
|
1348
|
+
return {
|
1349
|
+
key,
|
1350
|
+
edgeFunction,
|
1351
|
+
type: 'function',
|
1352
|
+
};
|
1353
|
+
}),
|
1354
|
+
];
|
1355
|
+
if (middlewareManifest && sortedFunctions.length > 0) {
|
1356
|
+
const workerConfigs = await Promise.all(sortedFunctions.map(async ({ key, edgeFunction, type }) => {
|
1342
1357
|
try {
|
1343
|
-
const wrappedModuleSource = await (0, get_edge_function_source_1.getNextjsEdgeFunctionSource)(
|
1344
|
-
name:
|
1358
|
+
const wrappedModuleSource = await (0, get_edge_function_source_1.getNextjsEdgeFunctionSource)(edgeFunction.files, {
|
1359
|
+
name: edgeFunction.name,
|
1345
1360
|
staticRoutes: routesManifest.staticRoutes,
|
1346
1361
|
dynamicRoutes: routesManifest.dynamicRoutes.filter(r => !('isMiddleware' in r)),
|
1347
1362
|
nextConfig: {
|
1348
1363
|
basePath: routesManifest.basePath,
|
1349
1364
|
i18n: routesManifest.i18n,
|
1350
1365
|
},
|
1351
|
-
}, path_1.default.resolve(entryPath, outputDirectory),
|
1366
|
+
}, path_1.default.resolve(entryPath, outputDirectory), edgeFunction.wasm);
|
1352
1367
|
return {
|
1353
|
-
|
1368
|
+
type,
|
1369
|
+
page: edgeFunction.page,
|
1354
1370
|
edgeFunction: (() => {
|
1355
1371
|
const { source, map } = wrappedModuleSource.sourceAndMap();
|
1356
1372
|
const transformedMap = (0, sourcemapped_1.stringifySourceMap)(transformSourceMap(map));
|
1357
|
-
const wasmFiles = (
|
1373
|
+
const wasmFiles = (edgeFunction.wasm ?? []).reduce((acc, { filePath, name }) => {
|
1358
1374
|
const fullFilePath = path_1.default.join(entryPath, outputDirectory, filePath);
|
1359
1375
|
acc[`wasm/${name}.wasm`] = new build_utils_1.FileFsRef({
|
1360
1376
|
mode: 0o644,
|
@@ -1365,7 +1381,7 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1365
1381
|
}, {});
|
1366
1382
|
return new build_utils_1.EdgeFunction({
|
1367
1383
|
deploymentTarget: 'v8-worker',
|
1368
|
-
name:
|
1384
|
+
name: edgeFunction.name,
|
1369
1385
|
files: {
|
1370
1386
|
'index.js': new build_utils_1.FileBlob({
|
1371
1387
|
data: source,
|
@@ -1382,10 +1398,10 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1382
1398
|
...wasmFiles,
|
1383
1399
|
},
|
1384
1400
|
entrypoint: 'index.js',
|
1385
|
-
envVarsInUse:
|
1401
|
+
envVarsInUse: edgeFunction.env,
|
1386
1402
|
});
|
1387
1403
|
})(),
|
1388
|
-
routeSrc: getRouteSrc(
|
1404
|
+
routeSrc: getRouteSrc(edgeFunction, routesManifest),
|
1389
1405
|
};
|
1390
1406
|
}
|
1391
1407
|
catch (e) {
|
@@ -1400,15 +1416,21 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
|
|
1400
1416
|
};
|
1401
1417
|
for (const worker of workerConfigs.values()) {
|
1402
1418
|
const edgeFile = worker.edgeFunction.name;
|
1403
|
-
|
1404
|
-
|
1419
|
+
const shortPath = edgeFile.replace(/^pages\//, '');
|
1420
|
+
worker.edgeFunction.name = shortPath;
|
1421
|
+
source.edgeFunctions[shortPath] = worker.edgeFunction;
|
1405
1422
|
const route = {
|
1406
1423
|
continue: true,
|
1407
|
-
middlewarePath: edgeFile,
|
1408
1424
|
src: worker.routeSrc,
|
1409
1425
|
};
|
1410
|
-
if (
|
1411
|
-
route.
|
1426
|
+
if (worker.type === 'function') {
|
1427
|
+
route.dest = shortPath;
|
1428
|
+
}
|
1429
|
+
else {
|
1430
|
+
route.middlewarePath = shortPath;
|
1431
|
+
if (isCorrectMiddlewareOrder) {
|
1432
|
+
route.override = true;
|
1433
|
+
}
|
1412
1434
|
}
|
1413
1435
|
if (routesManifest.version > 3 && isDynamicRoute(worker.page)) {
|
1414
1436
|
source.dynamicRouteMap.set(worker.page, route);
|
@@ -1442,6 +1464,7 @@ async function getMiddlewareManifest(entryPath, outputDirectory) {
|
|
1442
1464
|
}
|
1443
1465
|
return fs_extra_1.default.readJSON(middlewareManifestPath);
|
1444
1466
|
}
|
1467
|
+
exports.getMiddlewareManifest = getMiddlewareManifest;
|
1445
1468
|
/**
|
1446
1469
|
* For an object containing middleware info and a routes manifest this will
|
1447
1470
|
* generate a string with the route that will activate the middleware on
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.0.1-canary.
|
3
|
+
"version": "3.0.1-canary.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
@@ -70,5 +70,5 @@
|
|
70
70
|
"typescript": "4.5.2",
|
71
71
|
"webpack-sources": "3.2.3"
|
72
72
|
},
|
73
|
-
"gitHead": "
|
73
|
+
"gitHead": "6d42816395b5c37c44f14e5c42af5b458a029c03"
|
74
74
|
}
|