@vercel/next 3.1.12 → 3.1.13
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 +58 -18
- package/dist/server-build.js +58 -18
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -44826,6 +44826,7 @@ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
|
|
44826
44826
|
const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
|
44827
44827
|
const EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = 'v12.2.0';
|
44828
44828
|
const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
|
44829
|
+
const NON_NESTED_MIDDLEWARE_VERSION = 'v12.1.7-canary.9';
|
44829
44830
|
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, }) {
|
44830
44831
|
const lambdas = {};
|
44831
44832
|
const prerenders = {};
|
@@ -44836,6 +44837,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
44836
44837
|
const isCorrectNotFoundRoutes = semver_1.default.gte(nextVersion, CORRECT_NOT_FOUND_ROUTES_VERSION);
|
44837
44838
|
const isCorrectMiddlewareOrder = semver_1.default.gte(nextVersion, CORRECT_MIDDLEWARE_ORDER_VERSION);
|
44838
44839
|
const isCorrectManifests = semver_1.default.gte(nextVersion, CORRECTED_MANIFESTS_VERSION);
|
44840
|
+
const isNonNestedMiddleware = semver_1.default.gte(nextVersion, NON_NESTED_MIDDLEWARE_VERSION);
|
44839
44841
|
let hasStatic500 = !!staticPages[path_1.default.join(entryDirectory, '500')];
|
44840
44842
|
if (lambdaPageKeys.length === 0) {
|
44841
44843
|
throw new build_utils_1.NowBuildError({
|
@@ -45415,6 +45417,22 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45415
45417
|
fsPath: catchallFsPath,
|
45416
45418
|
});
|
45417
45419
|
}
|
45420
|
+
// We stopped duplicating matchers for _next/data routes when we added
|
45421
|
+
// x-nextjs-data header resolving but we should still resolve middleware
|
45422
|
+
// when the header isn't present so we augment the source to include that.
|
45423
|
+
// We don't apply this modification for nested middleware > 1 staticRoute
|
45424
|
+
if (isNonNestedMiddleware) {
|
45425
|
+
middleware.staticRoutes.forEach(route => {
|
45426
|
+
if (!route.src?.match(/_next[\\/]{1,}data/)) {
|
45427
|
+
route.src =
|
45428
|
+
`^(\\/_next\\/data\\/${escapedBuildId})?(` +
|
45429
|
+
route.src
|
45430
|
+
?.replace(/\|\^/g, '|')
|
45431
|
+
.replace(/\$$/, ')$')
|
45432
|
+
.replace(/\$/g, '(\\.json)?$');
|
45433
|
+
}
|
45434
|
+
});
|
45435
|
+
}
|
45418
45436
|
return {
|
45419
45437
|
wildcard: wildcardConfig,
|
45420
45438
|
images: imagesManifest?.images?.loader === 'default'
|
@@ -45540,15 +45558,15 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45540
45558
|
},
|
45541
45559
|
]
|
45542
45560
|
: []),
|
45543
|
-
// ensure prerender's for notFound: true static routes
|
45544
|
-
// have 404 status code when not in preview mode
|
45545
|
-
...notFoundPreviewRoutes,
|
45546
45561
|
...headers,
|
45547
45562
|
...redirects,
|
45548
45563
|
// middleware comes directly after redirects but before
|
45549
45564
|
// beforeFiles rewrites as middleware is not a "file" route
|
45550
45565
|
...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
|
45551
45566
|
...beforeFilesRewrites,
|
45567
|
+
// ensure prerender's for notFound: true static routes
|
45568
|
+
// have 404 status code when not in preview mode
|
45569
|
+
...notFoundPreviewRoutes,
|
45552
45570
|
// Make sure to 404 for the /404 path itself
|
45553
45571
|
...(i18n
|
45554
45572
|
? [
|
@@ -45637,7 +45655,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45637
45655
|
check: true,
|
45638
45656
|
dest: '$0',
|
45639
45657
|
},
|
45640
|
-
// remove locale prefixes to check public files
|
45658
|
+
// remove locale prefixes to check public files and
|
45659
|
+
// to allow checking non-prefixed lambda outputs
|
45641
45660
|
...(i18n
|
45642
45661
|
? [
|
45643
45662
|
{
|
@@ -45649,26 +45668,46 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45649
45668
|
},
|
45650
45669
|
]
|
45651
45670
|
: []),
|
45652
|
-
// for non-shared lambdas remove locale prefix if present
|
45653
|
-
// to allow checking for lambda
|
45654
|
-
...(!i18n
|
45655
|
-
? []
|
45656
|
-
: [
|
45657
|
-
{
|
45658
|
-
src: `${path_1.default.join('/', entryDirectory, '/')}(?:${i18n?.locales
|
45659
|
-
.map(locale => (0, escape_string_regexp_1.default)(locale))
|
45660
|
-
.join('|')})/(.*)`,
|
45661
|
-
dest: '/$1',
|
45662
|
-
check: true,
|
45663
|
-
},
|
45664
|
-
]),
|
45665
45671
|
// routes that are called after each rewrite or after routes
|
45666
45672
|
// if there no rewrites
|
45667
45673
|
{ handle: 'rewrite' },
|
45668
45674
|
// re-build /_next/data URL after resolving
|
45669
45675
|
...denormalizeNextDataRoute(),
|
45676
|
+
...(isNextDataServerResolving
|
45677
|
+
? dataRoutes.filter(route => {
|
45678
|
+
// filter to only static data routes as dynamic routes will be handled
|
45679
|
+
// below
|
45680
|
+
const { pathname } = new URL(route.dest || '/', 'http://n');
|
45681
|
+
return !(0, utils_1.isDynamicRoute)(pathname.replace(/\.json$/, ''));
|
45682
|
+
})
|
45683
|
+
: []),
|
45670
45684
|
// /_next/data routes for getServerProps/getStaticProps pages
|
45671
|
-
...
|
45685
|
+
...(isNextDataServerResolving
|
45686
|
+
? // when resolving data routes for middleware we need to include
|
45687
|
+
// all dynamic routes including non-SSG/SSP so that the priority
|
45688
|
+
// is correct
|
45689
|
+
dynamicRoutes
|
45690
|
+
.map(route => {
|
45691
|
+
route = Object.assign({}, route);
|
45692
|
+
route.src = path_1.default.posix.join('^/', entryDirectory, '_next/data/', escapedBuildId, route.src.replace(/(^\^|\$$)/g, '') + '.json$');
|
45693
|
+
const { pathname } = new URL(route.dest || '/', 'http://n');
|
45694
|
+
let isPrerender = !!prerenders[path_1.default.join('./', pathname)];
|
45695
|
+
if (routesManifest.i18n) {
|
45696
|
+
for (const locale of routesManifest.i18n?.locales || []) {
|
45697
|
+
const prerenderPathname = pathname.replace(/^\/\$nextLocale/, `/${locale}`);
|
45698
|
+
if (prerenders[path_1.default.join('./', prerenderPathname)]) {
|
45699
|
+
isPrerender = true;
|
45700
|
+
break;
|
45701
|
+
}
|
45702
|
+
}
|
45703
|
+
}
|
45704
|
+
if (isPrerender) {
|
45705
|
+
route.dest = `/_next/data/${buildId}${pathname}.json`;
|
45706
|
+
}
|
45707
|
+
return route;
|
45708
|
+
})
|
45709
|
+
.filter(Boolean)
|
45710
|
+
: dataRoutes),
|
45672
45711
|
...(!isNextDataServerResolving
|
45673
45712
|
? [
|
45674
45713
|
// ensure we 404 for non-existent _next/data routes before
|
@@ -45691,6 +45730,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
45691
45730
|
'x-nextjs-matched-path': '/$1',
|
45692
45731
|
},
|
45693
45732
|
continue: true,
|
45733
|
+
override: true,
|
45694
45734
|
},
|
45695
45735
|
// add a catch-all data route so we don't 404 when getting
|
45696
45736
|
// middleware effects
|
package/dist/server-build.js
CHANGED
@@ -21,6 +21,7 @@ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
|
|
21
21
|
const NEXT_DATA_MIDDLEWARE_RESOLVING_VERSION = 'v12.1.7-canary.33';
|
22
22
|
const EMPTY_ALLOW_QUERY_FOR_PRERENDERED_VERSION = 'v12.2.0';
|
23
23
|
const CORRECTED_MANIFESTS_VERSION = 'v12.2.0';
|
24
|
+
const NON_NESTED_MIDDLEWARE_VERSION = 'v12.1.7-canary.9';
|
24
25
|
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, }) {
|
25
26
|
const lambdas = {};
|
26
27
|
const prerenders = {};
|
@@ -31,6 +32,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
31
32
|
const isCorrectNotFoundRoutes = semver_1.default.gte(nextVersion, CORRECT_NOT_FOUND_ROUTES_VERSION);
|
32
33
|
const isCorrectMiddlewareOrder = semver_1.default.gte(nextVersion, CORRECT_MIDDLEWARE_ORDER_VERSION);
|
33
34
|
const isCorrectManifests = semver_1.default.gte(nextVersion, CORRECTED_MANIFESTS_VERSION);
|
35
|
+
const isNonNestedMiddleware = semver_1.default.gte(nextVersion, NON_NESTED_MIDDLEWARE_VERSION);
|
34
36
|
let hasStatic500 = !!staticPages[path_1.default.join(entryDirectory, '500')];
|
35
37
|
if (lambdaPageKeys.length === 0) {
|
36
38
|
throw new build_utils_1.NowBuildError({
|
@@ -610,6 +612,22 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
610
612
|
fsPath: catchallFsPath,
|
611
613
|
});
|
612
614
|
}
|
615
|
+
// We stopped duplicating matchers for _next/data routes when we added
|
616
|
+
// x-nextjs-data header resolving but we should still resolve middleware
|
617
|
+
// when the header isn't present so we augment the source to include that.
|
618
|
+
// We don't apply this modification for nested middleware > 1 staticRoute
|
619
|
+
if (isNonNestedMiddleware) {
|
620
|
+
middleware.staticRoutes.forEach(route => {
|
621
|
+
if (!route.src?.match(/_next[\\/]{1,}data/)) {
|
622
|
+
route.src =
|
623
|
+
`^(\\/_next\\/data\\/${escapedBuildId})?(` +
|
624
|
+
route.src
|
625
|
+
?.replace(/\|\^/g, '|')
|
626
|
+
.replace(/\$$/, ')$')
|
627
|
+
.replace(/\$/g, '(\\.json)?$');
|
628
|
+
}
|
629
|
+
});
|
630
|
+
}
|
613
631
|
return {
|
614
632
|
wildcard: wildcardConfig,
|
615
633
|
images: imagesManifest?.images?.loader === 'default'
|
@@ -735,15 +753,15 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
735
753
|
},
|
736
754
|
]
|
737
755
|
: []),
|
738
|
-
// ensure prerender's for notFound: true static routes
|
739
|
-
// have 404 status code when not in preview mode
|
740
|
-
...notFoundPreviewRoutes,
|
741
756
|
...headers,
|
742
757
|
...redirects,
|
743
758
|
// middleware comes directly after redirects but before
|
744
759
|
// beforeFiles rewrites as middleware is not a "file" route
|
745
760
|
...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
|
746
761
|
...beforeFilesRewrites,
|
762
|
+
// ensure prerender's for notFound: true static routes
|
763
|
+
// have 404 status code when not in preview mode
|
764
|
+
...notFoundPreviewRoutes,
|
747
765
|
// Make sure to 404 for the /404 path itself
|
748
766
|
...(i18n
|
749
767
|
? [
|
@@ -832,7 +850,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
832
850
|
check: true,
|
833
851
|
dest: '$0',
|
834
852
|
},
|
835
|
-
// remove locale prefixes to check public files
|
853
|
+
// remove locale prefixes to check public files and
|
854
|
+
// to allow checking non-prefixed lambda outputs
|
836
855
|
...(i18n
|
837
856
|
? [
|
838
857
|
{
|
@@ -844,26 +863,46 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
844
863
|
},
|
845
864
|
]
|
846
865
|
: []),
|
847
|
-
// for non-shared lambdas remove locale prefix if present
|
848
|
-
// to allow checking for lambda
|
849
|
-
...(!i18n
|
850
|
-
? []
|
851
|
-
: [
|
852
|
-
{
|
853
|
-
src: `${path_1.default.join('/', entryDirectory, '/')}(?:${i18n?.locales
|
854
|
-
.map(locale => (0, escape_string_regexp_1.default)(locale))
|
855
|
-
.join('|')})/(.*)`,
|
856
|
-
dest: '/$1',
|
857
|
-
check: true,
|
858
|
-
},
|
859
|
-
]),
|
860
866
|
// routes that are called after each rewrite or after routes
|
861
867
|
// if there no rewrites
|
862
868
|
{ handle: 'rewrite' },
|
863
869
|
// re-build /_next/data URL after resolving
|
864
870
|
...denormalizeNextDataRoute(),
|
871
|
+
...(isNextDataServerResolving
|
872
|
+
? dataRoutes.filter(route => {
|
873
|
+
// filter to only static data routes as dynamic routes will be handled
|
874
|
+
// below
|
875
|
+
const { pathname } = new URL(route.dest || '/', 'http://n');
|
876
|
+
return !(0, utils_1.isDynamicRoute)(pathname.replace(/\.json$/, ''));
|
877
|
+
})
|
878
|
+
: []),
|
865
879
|
// /_next/data routes for getServerProps/getStaticProps pages
|
866
|
-
...
|
880
|
+
...(isNextDataServerResolving
|
881
|
+
? // when resolving data routes for middleware we need to include
|
882
|
+
// all dynamic routes including non-SSG/SSP so that the priority
|
883
|
+
// is correct
|
884
|
+
dynamicRoutes
|
885
|
+
.map(route => {
|
886
|
+
route = Object.assign({}, route);
|
887
|
+
route.src = path_1.default.posix.join('^/', entryDirectory, '_next/data/', escapedBuildId, route.src.replace(/(^\^|\$$)/g, '') + '.json$');
|
888
|
+
const { pathname } = new URL(route.dest || '/', 'http://n');
|
889
|
+
let isPrerender = !!prerenders[path_1.default.join('./', pathname)];
|
890
|
+
if (routesManifest.i18n) {
|
891
|
+
for (const locale of routesManifest.i18n?.locales || []) {
|
892
|
+
const prerenderPathname = pathname.replace(/^\/\$nextLocale/, `/${locale}`);
|
893
|
+
if (prerenders[path_1.default.join('./', prerenderPathname)]) {
|
894
|
+
isPrerender = true;
|
895
|
+
break;
|
896
|
+
}
|
897
|
+
}
|
898
|
+
}
|
899
|
+
if (isPrerender) {
|
900
|
+
route.dest = `/_next/data/${buildId}${pathname}.json`;
|
901
|
+
}
|
902
|
+
return route;
|
903
|
+
})
|
904
|
+
.filter(Boolean)
|
905
|
+
: dataRoutes),
|
867
906
|
...(!isNextDataServerResolving
|
868
907
|
? [
|
869
908
|
// ensure we 404 for non-existent _next/data routes before
|
@@ -886,6 +925,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
|
|
886
925
|
'x-nextjs-matched-path': '/$1',
|
887
926
|
},
|
888
927
|
continue: true,
|
928
|
+
override: true,
|
889
929
|
},
|
890
930
|
// add a catch-all data route so we don't 404 when getting
|
891
931
|
// middleware effects
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/next",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.13",
|
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": "5.0
|
48
|
+
"@vercel/build-utils": "5.1.0",
|
49
49
|
"@vercel/nft": "0.21.0",
|
50
50
|
"@vercel/routing-utils": "2.0.0",
|
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": "7db6436797d0b4131113f0b8dccc3b66bc9b1981"
|
74
74
|
}
|