@vercel/next 3.1.10 → 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 +47649 -11
- package/dist/server-build.js +58 -18
- package/package.json +3 -3
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
|
}
|