@vercel/next 3.1.1 → 3.1.4-canary.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/dist/index.js +80 -44
- package/dist/server-build.js +34 -16
- package/dist/utils.js +6 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -42553,6 +42553,13 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
42553
42553
|
const nextVersionRange = await getNextVersionRange(entryPath);
|
42554
42554
|
const nodeVersion = await (0, build_utils_1.getNodeVersion)(entryPath, undefined, config, meta);
|
42555
42555
|
const spawnOpts = (0, build_utils_1.getSpawnOptions)(meta, nodeVersion);
|
42556
|
+
const { cliType, lockfileVersion } = await (0, build_utils_1.scanParentDirs)(entryPath);
|
42557
|
+
spawnOpts.env = (0, build_utils_1.getEnvForPackageManager)({
|
42558
|
+
cliType,
|
42559
|
+
lockfileVersion,
|
42560
|
+
nodeVersion,
|
42561
|
+
env: spawnOpts.env || {},
|
42562
|
+
});
|
42556
42563
|
const nowJsonPath = await (0, find_up_1.default)(['now.json', 'vercel.json'], {
|
42557
42564
|
cwd: entryPath,
|
42558
42565
|
});
|
@@ -42600,25 +42607,8 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
42600
42607
|
if (typeof installCommand === 'string') {
|
42601
42608
|
if (installCommand.trim()) {
|
42602
42609
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
42603
|
-
const { cliType, lockfileVersion } = await (0, build_utils_1.scanParentDirs)(entryPath);
|
42604
|
-
const env = {
|
42605
|
-
YARN_NODE_LINKER: 'node-modules',
|
42606
|
-
...spawnOpts.env,
|
42607
|
-
};
|
42608
|
-
if (cliType === 'npm') {
|
42609
|
-
if (typeof lockfileVersion === 'number' &&
|
42610
|
-
lockfileVersion >= 2 &&
|
42611
|
-
(nodeVersion?.major || 0) < 16) {
|
42612
|
-
// Ensure that npm 7 is at the beginning of the `$PATH`
|
42613
|
-
env.PATH = `/node16/bin-npm7${path_1.default.delimiter}${env.PATH}`;
|
42614
|
-
console.log('Detected `package-lock.json` generated by npm 7...');
|
42615
|
-
}
|
42616
|
-
}
|
42617
42610
|
await (0, build_utils_1.execCommand)(installCommand, {
|
42618
42611
|
...spawnOpts,
|
42619
|
-
// Yarn v2 PnP mode may be activated, so force
|
42620
|
-
// "node-modules" linker style
|
42621
|
-
env,
|
42622
42612
|
cwd: entryPath,
|
42623
42613
|
});
|
42624
42614
|
}
|
@@ -43059,6 +43049,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
43059
43049
|
await (0, fs_extra_1.remove)(path_1.default.join(entryPath, '.npmrc'));
|
43060
43050
|
}
|
43061
43051
|
const trailingSlashRedirects = [];
|
43052
|
+
let trailingSlash = false;
|
43062
43053
|
redirects = redirects.filter(_redir => {
|
43063
43054
|
const redir = _redir;
|
43064
43055
|
// detect the trailing slash redirect and make sure it's
|
@@ -43072,6 +43063,9 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
43072
43063
|
// moving underneath i18n routes
|
43073
43064
|
redir.continue = true;
|
43074
43065
|
trailingSlashRedirects.push(redir);
|
43066
|
+
if (location === '/$1/') {
|
43067
|
+
trailingSlash = true;
|
43068
|
+
}
|
43075
43069
|
return false;
|
43076
43070
|
}
|
43077
43071
|
return true;
|
@@ -43284,6 +43278,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
43284
43278
|
return (0, server_build_1.serverBuild)({
|
43285
43279
|
config,
|
43286
43280
|
nextVersion,
|
43281
|
+
trailingSlash,
|
43287
43282
|
dynamicPages,
|
43288
43283
|
canUsePreviewMode,
|
43289
43284
|
staticPages,
|
@@ -43443,11 +43438,34 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
|
|
43443
43438
|
const apiLambdaGroups = [];
|
43444
43439
|
const pageLambdaGroups = [];
|
43445
43440
|
if (isSharedLambdas) {
|
43446
|
-
const initialPageLambdaGroups = await (0, utils_1.getPageLambdaGroups)(
|
43447
|
-
|
43448
|
-
|
43449
|
-
|
43450
|
-
|
43441
|
+
const initialPageLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
|
43442
|
+
entryPath,
|
43443
|
+
config,
|
43444
|
+
pages: nonApiPages,
|
43445
|
+
prerenderRoutes: new Set(),
|
43446
|
+
pageTraces,
|
43447
|
+
compressedPages,
|
43448
|
+
tracedPseudoLayer: tracedPseudoLayer?.pseudoLayer || {},
|
43449
|
+
initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
|
43450
|
+
initialPseudoLayerUncompressed: 0,
|
43451
|
+
lambdaCompressedByteLimit,
|
43452
|
+
// internal pages are already referenced in traces for serverless
|
43453
|
+
// like builds
|
43454
|
+
internalPages: [],
|
43455
|
+
});
|
43456
|
+
const initialApiLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
|
43457
|
+
entryPath,
|
43458
|
+
config,
|
43459
|
+
pages: apiPages,
|
43460
|
+
prerenderRoutes: new Set(),
|
43461
|
+
pageTraces,
|
43462
|
+
compressedPages,
|
43463
|
+
tracedPseudoLayer: tracedPseudoLayer?.pseudoLayer || {},
|
43464
|
+
initialPseudoLayer: { pseudoLayer: {}, pseudoLayerBytes: 0 },
|
43465
|
+
initialPseudoLayerUncompressed: 0,
|
43466
|
+
lambdaCompressedByteLimit,
|
43467
|
+
internalPages: [],
|
43468
|
+
});
|
43451
43469
|
(0, build_utils_1.debug)(JSON.stringify({
|
43452
43470
|
apiLambdaGroups: initialApiLambdaGroups.map(group => ({
|
43453
43471
|
pages: group.pages,
|
@@ -44614,7 +44632,7 @@ const pretty_bytes_1 = __importDefault(__webpack_require__(539));
|
|
44614
44632
|
const CORRECT_NOT_FOUND_ROUTES_VERSION = 'v12.0.1';
|
44615
44633
|
const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
|
44616
44634
|
const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
|
44617
|
-
async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
|
44635
|
+
async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, trailingSlash, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
|
44618
44636
|
const lambdas = {};
|
44619
44637
|
const prerenders = {};
|
44620
44638
|
const lambdaPageKeys = Object.keys(lambdaPages);
|
@@ -44814,9 +44832,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
44814
44832
|
Object.assign(initialPseudoLayer.pseudoLayer, requiredFilesLayer.pseudoLayer);
|
44815
44833
|
initialPseudoLayer.pseudoLayerBytes += requiredFilesLayer.pseudoLayerBytes;
|
44816
44834
|
const uncompressedInitialSize = Object.keys(initialPseudoLayer.pseudoLayer).reduce((prev, cur) => {
|
44817
|
-
|
44818
|
-
|
44819
|
-
.uncompressedSize || 0);
|
44835
|
+
const file = initialPseudoLayer.pseudoLayer[cur];
|
44836
|
+
return prev + file.uncompressedSize || 0;
|
44820
44837
|
}, 0);
|
44821
44838
|
(0, build_utils_1.debug)(JSON.stringify({
|
44822
44839
|
uncompressedInitialSize,
|
@@ -44911,13 +44928,34 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
44911
44928
|
Object.assign(prev, pageTraces[page]);
|
44912
44929
|
return prev;
|
44913
44930
|
}, {}));
|
44914
|
-
const initialPseudoLayerSize = Object.keys(initialPseudoLayer.pseudoLayer).reduce((prev, cur) => {
|
44915
|
-
const file = initialPseudoLayer.pseudoLayer[cur];
|
44916
|
-
return prev + file.uncompressedSize || 0;
|
44917
|
-
}, 0);
|
44918
44931
|
const pageExtensions = requiredServerFilesManifest.config?.pageExtensions;
|
44919
|
-
const pageLambdaGroups = await (0, utils_1.getPageLambdaGroups)(
|
44920
|
-
|
44932
|
+
const pageLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
|
44933
|
+
entryPath: requiredServerFilesManifest.appDir || entryPath,
|
44934
|
+
config,
|
44935
|
+
pages: nonApiPages,
|
44936
|
+
prerenderRoutes,
|
44937
|
+
pageTraces,
|
44938
|
+
compressedPages,
|
44939
|
+
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
44940
|
+
initialPseudoLayer,
|
44941
|
+
lambdaCompressedByteLimit,
|
44942
|
+
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
44943
|
+
internalPages,
|
44944
|
+
pageExtensions,
|
44945
|
+
});
|
44946
|
+
const apiLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
|
44947
|
+
entryPath: requiredServerFilesManifest.appDir || entryPath,
|
44948
|
+
config,
|
44949
|
+
pages: apiPages,
|
44950
|
+
prerenderRoutes,
|
44951
|
+
pageTraces,
|
44952
|
+
compressedPages,
|
44953
|
+
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
44954
|
+
initialPseudoLayer,
|
44955
|
+
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
44956
|
+
lambdaCompressedByteLimit,
|
44957
|
+
internalPages,
|
44958
|
+
});
|
44921
44959
|
(0, build_utils_1.debug)(JSON.stringify({
|
44922
44960
|
apiLambdaGroups: apiLambdaGroups.map(group => ({
|
44923
44961
|
pages: group.pages,
|
@@ -44939,7 +44977,6 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
44939
44977
|
const lambda = await (0, utils_1.createLambdaFromPseudoLayers)({
|
44940
44978
|
files: launcherFiles,
|
44941
44979
|
layers: [
|
44942
|
-
initialPseudoLayer.pseudoLayer,
|
44943
44980
|
group.pseudoLayer,
|
44944
44981
|
[...group.pages, ...internalPages].reduce((prev, page) => {
|
44945
44982
|
const pageFileName = path_1.default.normalize(path_1.default.relative(baseDir, lambdaPages[page].fsPath));
|
@@ -45064,7 +45101,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45064
45101
|
// strip _next/data prefix for resolving
|
45065
45102
|
{
|
45066
45103
|
src: `^${path_1.default.join('/', entryDirectory, '/_next/data/', escapedBuildId, '/(.*).json')}`,
|
45067
|
-
dest: `${path_1.default.join('/', entryDirectory, '/$1')}`,
|
45104
|
+
dest: `${path_1.default.join('/', entryDirectory, '/$1', trailingSlash ? '/' : '')}`,
|
45068
45105
|
...(isOverride ? { override: true } : {}),
|
45069
45106
|
continue: true,
|
45070
45107
|
has: [
|
@@ -45077,14 +45114,14 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45077
45114
|
// normalize "/index" from "/_next/data/index.json" to -> just "/"
|
45078
45115
|
// as matches a rewrite sources will expect just "/"
|
45079
45116
|
{
|
45080
|
-
src: path_1.default.join('^/', entryDirectory, '/index'),
|
45117
|
+
src: path_1.default.join('^/', entryDirectory, '/index(?:/)?'),
|
45081
45118
|
has: [
|
45082
45119
|
{
|
45083
45120
|
type: 'header',
|
45084
45121
|
key: 'x-nextjs-data',
|
45085
45122
|
},
|
45086
45123
|
],
|
45087
|
-
dest: path_1.default.join('/', entryDirectory),
|
45124
|
+
dest: path_1.default.join('/', entryDirectory, trailingSlash ? '/' : ''),
|
45088
45125
|
...(isOverride ? { override: true } : {}),
|
45089
45126
|
continue: true,
|
45090
45127
|
},
|
@@ -45095,7 +45132,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45095
45132
|
return isNextDataServerResolving
|
45096
45133
|
? [
|
45097
45134
|
{
|
45098
|
-
src: path_1.default.join('^/', entryDirectory, '$'),
|
45135
|
+
src: path_1.default.join('^/', entryDirectory, trailingSlash ? '/' : '', '$'),
|
45099
45136
|
has: [
|
45100
45137
|
{
|
45101
45138
|
type: 'header',
|
@@ -45106,7 +45143,6 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45106
45143
|
continue: true,
|
45107
45144
|
...(isOverride ? { override: true } : {}),
|
45108
45145
|
},
|
45109
|
-
// handle non-trailing slash
|
45110
45146
|
{
|
45111
45147
|
src: path_1.default.join('^/', entryDirectory, '((?!_next/)(?:.*[^/]|.*))/?$'),
|
45112
45148
|
has: [
|
@@ -46398,7 +46434,7 @@ exports.addLocaleOrDefault = addLocaleOrDefault;
|
|
46398
46434
|
exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * 1000 * 1000; // 250MB
|
46399
46435
|
const LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 2.5 * 1000 * 1000; // 2.5MB
|
46400
46436
|
const LAMBDA_RESERVED_COMPRESSED_SIZE = 250 * 1000; // 250KB
|
46401
|
-
async function getPageLambdaGroups(entryPath, config, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer,
|
46437
|
+
async function getPageLambdaGroups({ entryPath, config, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer, initialPseudoLayer, initialPseudoLayerUncompressed, lambdaCompressedByteLimit, internalPages, pageExtensions, }) {
|
46402
46438
|
const groups = [];
|
46403
46439
|
for (const page of pages) {
|
46404
46440
|
const newPages = [...internalPages, page];
|
@@ -46435,9 +46471,9 @@ async function getPageLambdaGroups(entryPath, config, pages, prerenderRoutes, pa
|
|
46435
46471
|
newTracedFilesUncompressedSize +=
|
46436
46472
|
compressedPages[newPage].uncompressedSize;
|
46437
46473
|
}
|
46438
|
-
const underUncompressedLimit = newTracedFilesUncompressedSize
|
46474
|
+
const underUncompressedLimit = newTracedFilesUncompressedSize <
|
46439
46475
|
exports.MAX_UNCOMPRESSED_LAMBDA_SIZE - LAMBDA_RESERVED_UNCOMPRESSED_SIZE;
|
46440
|
-
const underCompressedLimit = newTracedFilesSize
|
46476
|
+
const underCompressedLimit = newTracedFilesSize <
|
46441
46477
|
lambdaCompressedByteLimit - LAMBDA_RESERVED_COMPRESSED_SIZE;
|
46442
46478
|
return underUncompressedLimit && underCompressedLimit;
|
46443
46479
|
}
|
@@ -46451,9 +46487,9 @@ async function getPageLambdaGroups(entryPath, config, pages, prerenderRoutes, pa
|
|
46451
46487
|
pages: [page],
|
46452
46488
|
...opts,
|
46453
46489
|
isPrerenders: isPrerenderRoute,
|
46454
|
-
pseudoLayerBytes:
|
46455
|
-
pseudoLayerUncompressedBytes:
|
46456
|
-
pseudoLayer: {},
|
46490
|
+
pseudoLayerBytes: initialPseudoLayer.pseudoLayerBytes,
|
46491
|
+
pseudoLayerUncompressedBytes: initialPseudoLayerUncompressed,
|
46492
|
+
pseudoLayer: Object.assign({}, initialPseudoLayer.pseudoLayer),
|
46457
46493
|
};
|
46458
46494
|
groups.push(newGroup);
|
46459
46495
|
matchingGroup = newGroup;
|
package/dist/server-build.js
CHANGED
@@ -19,7 +19,7 @@ const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
|
|
19
19
|
const CORRECT_NOT_FOUND_ROUTES_VERSION = 'v12.0.1';
|
20
20
|
const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
|
21
21
|
const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
|
22
|
-
async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
|
22
|
+
async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, buildId, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, trailingSlash, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
|
23
23
|
const lambdas = {};
|
24
24
|
const prerenders = {};
|
25
25
|
const lambdaPageKeys = Object.keys(lambdaPages);
|
@@ -219,9 +219,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
219
219
|
Object.assign(initialPseudoLayer.pseudoLayer, requiredFilesLayer.pseudoLayer);
|
220
220
|
initialPseudoLayer.pseudoLayerBytes += requiredFilesLayer.pseudoLayerBytes;
|
221
221
|
const uncompressedInitialSize = Object.keys(initialPseudoLayer.pseudoLayer).reduce((prev, cur) => {
|
222
|
-
|
223
|
-
|
224
|
-
.uncompressedSize || 0);
|
222
|
+
const file = initialPseudoLayer.pseudoLayer[cur];
|
223
|
+
return prev + file.uncompressedSize || 0;
|
225
224
|
}, 0);
|
226
225
|
(0, build_utils_1.debug)(JSON.stringify({
|
227
226
|
uncompressedInitialSize,
|
@@ -316,13 +315,34 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
316
315
|
Object.assign(prev, pageTraces[page]);
|
317
316
|
return prev;
|
318
317
|
}, {}));
|
319
|
-
const initialPseudoLayerSize = Object.keys(initialPseudoLayer.pseudoLayer).reduce((prev, cur) => {
|
320
|
-
const file = initialPseudoLayer.pseudoLayer[cur];
|
321
|
-
return prev + file.uncompressedSize || 0;
|
322
|
-
}, 0);
|
323
318
|
const pageExtensions = requiredServerFilesManifest.config?.pageExtensions;
|
324
|
-
const pageLambdaGroups = await (0, utils_1.getPageLambdaGroups)(
|
325
|
-
|
319
|
+
const pageLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
|
320
|
+
entryPath: requiredServerFilesManifest.appDir || entryPath,
|
321
|
+
config,
|
322
|
+
pages: nonApiPages,
|
323
|
+
prerenderRoutes,
|
324
|
+
pageTraces,
|
325
|
+
compressedPages,
|
326
|
+
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
327
|
+
initialPseudoLayer,
|
328
|
+
lambdaCompressedByteLimit,
|
329
|
+
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
330
|
+
internalPages,
|
331
|
+
pageExtensions,
|
332
|
+
});
|
333
|
+
const apiLambdaGroups = await (0, utils_1.getPageLambdaGroups)({
|
334
|
+
entryPath: requiredServerFilesManifest.appDir || entryPath,
|
335
|
+
config,
|
336
|
+
pages: apiPages,
|
337
|
+
prerenderRoutes,
|
338
|
+
pageTraces,
|
339
|
+
compressedPages,
|
340
|
+
tracedPseudoLayer: tracedPseudoLayer.pseudoLayer,
|
341
|
+
initialPseudoLayer,
|
342
|
+
initialPseudoLayerUncompressed: uncompressedInitialSize,
|
343
|
+
lambdaCompressedByteLimit,
|
344
|
+
internalPages,
|
345
|
+
});
|
326
346
|
(0, build_utils_1.debug)(JSON.stringify({
|
327
347
|
apiLambdaGroups: apiLambdaGroups.map(group => ({
|
328
348
|
pages: group.pages,
|
@@ -344,7 +364,6 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
344
364
|
const lambda = await (0, utils_1.createLambdaFromPseudoLayers)({
|
345
365
|
files: launcherFiles,
|
346
366
|
layers: [
|
347
|
-
initialPseudoLayer.pseudoLayer,
|
348
367
|
group.pseudoLayer,
|
349
368
|
[...group.pages, ...internalPages].reduce((prev, page) => {
|
350
369
|
const pageFileName = path_1.default.normalize(path_1.default.relative(baseDir, lambdaPages[page].fsPath));
|
@@ -469,7 +488,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
469
488
|
// strip _next/data prefix for resolving
|
470
489
|
{
|
471
490
|
src: `^${path_1.default.join('/', entryDirectory, '/_next/data/', escapedBuildId, '/(.*).json')}`,
|
472
|
-
dest: `${path_1.default.join('/', entryDirectory, '/$1')}`,
|
491
|
+
dest: `${path_1.default.join('/', entryDirectory, '/$1', trailingSlash ? '/' : '')}`,
|
473
492
|
...(isOverride ? { override: true } : {}),
|
474
493
|
continue: true,
|
475
494
|
has: [
|
@@ -482,14 +501,14 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
482
501
|
// normalize "/index" from "/_next/data/index.json" to -> just "/"
|
483
502
|
// as matches a rewrite sources will expect just "/"
|
484
503
|
{
|
485
|
-
src: path_1.default.join('^/', entryDirectory, '/index'),
|
504
|
+
src: path_1.default.join('^/', entryDirectory, '/index(?:/)?'),
|
486
505
|
has: [
|
487
506
|
{
|
488
507
|
type: 'header',
|
489
508
|
key: 'x-nextjs-data',
|
490
509
|
},
|
491
510
|
],
|
492
|
-
dest: path_1.default.join('/', entryDirectory),
|
511
|
+
dest: path_1.default.join('/', entryDirectory, trailingSlash ? '/' : ''),
|
493
512
|
...(isOverride ? { override: true } : {}),
|
494
513
|
continue: true,
|
495
514
|
},
|
@@ -500,7 +519,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
500
519
|
return isNextDataServerResolving
|
501
520
|
? [
|
502
521
|
{
|
503
|
-
src: path_1.default.join('^/', entryDirectory, '$'),
|
522
|
+
src: path_1.default.join('^/', entryDirectory, trailingSlash ? '/' : '', '$'),
|
504
523
|
has: [
|
505
524
|
{
|
506
525
|
type: 'header',
|
@@ -511,7 +530,6 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
511
530
|
continue: true,
|
512
531
|
...(isOverride ? { override: true } : {}),
|
513
532
|
},
|
514
|
-
// handle non-trailing slash
|
515
533
|
{
|
516
534
|
src: path_1.default.join('^/', entryDirectory, '((?!_next/)(?:.*[^/]|.*))/?$'),
|
517
535
|
has: [
|
package/dist/utils.js
CHANGED
@@ -783,7 +783,7 @@ exports.addLocaleOrDefault = addLocaleOrDefault;
|
|
783
783
|
exports.MAX_UNCOMPRESSED_LAMBDA_SIZE = 250 * 1000 * 1000; // 250MB
|
784
784
|
const LAMBDA_RESERVED_UNCOMPRESSED_SIZE = 2.5 * 1000 * 1000; // 2.5MB
|
785
785
|
const LAMBDA_RESERVED_COMPRESSED_SIZE = 250 * 1000; // 250KB
|
786
|
-
async function getPageLambdaGroups(entryPath, config, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer,
|
786
|
+
async function getPageLambdaGroups({ entryPath, config, pages, prerenderRoutes, pageTraces, compressedPages, tracedPseudoLayer, initialPseudoLayer, initialPseudoLayerUncompressed, lambdaCompressedByteLimit, internalPages, pageExtensions, }) {
|
787
787
|
const groups = [];
|
788
788
|
for (const page of pages) {
|
789
789
|
const newPages = [...internalPages, page];
|
@@ -820,9 +820,9 @@ async function getPageLambdaGroups(entryPath, config, pages, prerenderRoutes, pa
|
|
820
820
|
newTracedFilesUncompressedSize +=
|
821
821
|
compressedPages[newPage].uncompressedSize;
|
822
822
|
}
|
823
|
-
const underUncompressedLimit = newTracedFilesUncompressedSize
|
823
|
+
const underUncompressedLimit = newTracedFilesUncompressedSize <
|
824
824
|
exports.MAX_UNCOMPRESSED_LAMBDA_SIZE - LAMBDA_RESERVED_UNCOMPRESSED_SIZE;
|
825
|
-
const underCompressedLimit = newTracedFilesSize
|
825
|
+
const underCompressedLimit = newTracedFilesSize <
|
826
826
|
lambdaCompressedByteLimit - LAMBDA_RESERVED_COMPRESSED_SIZE;
|
827
827
|
return underUncompressedLimit && underCompressedLimit;
|
828
828
|
}
|
@@ -836,9 +836,9 @@ async function getPageLambdaGroups(entryPath, config, pages, prerenderRoutes, pa
|
|
836
836
|
pages: [page],
|
837
837
|
...opts,
|
838
838
|
isPrerenders: isPrerenderRoute,
|
839
|
-
pseudoLayerBytes:
|
840
|
-
pseudoLayerUncompressedBytes:
|
841
|
-
pseudoLayer: {},
|
839
|
+
pseudoLayerBytes: initialPseudoLayer.pseudoLayerBytes,
|
840
|
+
pseudoLayerUncompressedBytes: initialPseudoLayerUncompressed,
|
841
|
+
pseudoLayer: Object.assign({}, initialPseudoLayer.pseudoLayer),
|
842
842
|
};
|
843
843
|
groups.push(newGroup);
|
844
844
|
matchingGroup = newGroup;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.4-canary.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index",
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
@@ -45,7 +45,7 @@
|
|
45
45
|
"@types/semver": "6.0.0",
|
46
46
|
"@types/text-table": "0.2.1",
|
47
47
|
"@types/webpack-sources": "3.2.0",
|
48
|
-
"@vercel/build-utils": "
|
48
|
+
"@vercel/build-utils": "5.0.0",
|
49
49
|
"@vercel/nft": "0.20.1",
|
50
50
|
"@vercel/routing-utils": "1.13.5",
|
51
51
|
"async-sema": "3.0.1",
|
@@ -70,5 +70,5 @@
|
|
70
70
|
"typescript": "4.5.2",
|
71
71
|
"webpack-sources": "3.2.3"
|
72
72
|
},
|
73
|
-
"gitHead": "
|
73
|
+
"gitHead": "ce89f00328af2c601317a919db81a4227f62c78e"
|
74
74
|
}
|