@vercel/next 3.1.11 → 3.1.14

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 CHANGED
@@ -45540,15 +45540,15 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
45540
45540
  },
45541
45541
  ]
45542
45542
  : []),
45543
- // ensure prerender's for notFound: true static routes
45544
- // have 404 status code when not in preview mode
45545
- ...notFoundPreviewRoutes,
45546
45543
  ...headers,
45547
45544
  ...redirects,
45548
45545
  // middleware comes directly after redirects but before
45549
45546
  // beforeFiles rewrites as middleware is not a "file" route
45550
45547
  ...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
45551
45548
  ...beforeFilesRewrites,
45549
+ // ensure prerender's for notFound: true static routes
45550
+ // have 404 status code when not in preview mode
45551
+ ...notFoundPreviewRoutes,
45552
45552
  // Make sure to 404 for the /404 path itself
45553
45553
  ...(i18n
45554
45554
  ? [
@@ -45637,7 +45637,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
45637
45637
  check: true,
45638
45638
  dest: '$0',
45639
45639
  },
45640
- // remove locale prefixes to check public files
45640
+ // remove locale prefixes to check public files and
45641
+ // to allow checking non-prefixed lambda outputs
45641
45642
  ...(i18n
45642
45643
  ? [
45643
45644
  {
@@ -45649,26 +45650,46 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
45649
45650
  },
45650
45651
  ]
45651
45652
  : []),
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
45653
  // routes that are called after each rewrite or after routes
45666
45654
  // if there no rewrites
45667
45655
  { handle: 'rewrite' },
45668
45656
  // re-build /_next/data URL after resolving
45669
45657
  ...denormalizeNextDataRoute(),
45658
+ ...(isNextDataServerResolving
45659
+ ? dataRoutes.filter(route => {
45660
+ // filter to only static data routes as dynamic routes will be handled
45661
+ // below
45662
+ const { pathname } = new URL(route.dest || '/', 'http://n');
45663
+ return !(0, utils_1.isDynamicRoute)(pathname.replace(/\.json$/, ''));
45664
+ })
45665
+ : []),
45670
45666
  // /_next/data routes for getServerProps/getStaticProps pages
45671
- ...dataRoutes,
45667
+ ...(isNextDataServerResolving
45668
+ ? // when resolving data routes for middleware we need to include
45669
+ // all dynamic routes including non-SSG/SSP so that the priority
45670
+ // is correct
45671
+ dynamicRoutes
45672
+ .map(route => {
45673
+ route = Object.assign({}, route);
45674
+ route.src = path_1.default.posix.join('^/', entryDirectory, '_next/data/', escapedBuildId, route.src.replace(/(^\^|\$$)/g, '') + '.json$');
45675
+ const { pathname } = new URL(route.dest || '/', 'http://n');
45676
+ let isPrerender = !!prerenders[path_1.default.join('./', pathname)];
45677
+ if (routesManifest.i18n) {
45678
+ for (const locale of routesManifest.i18n?.locales || []) {
45679
+ const prerenderPathname = pathname.replace(/^\/\$nextLocale/, `/${locale}`);
45680
+ if (prerenders[path_1.default.join('./', prerenderPathname)]) {
45681
+ isPrerender = true;
45682
+ break;
45683
+ }
45684
+ }
45685
+ }
45686
+ if (isPrerender) {
45687
+ route.dest = `/_next/data/${buildId}${pathname}.json`;
45688
+ }
45689
+ return route;
45690
+ })
45691
+ .filter(Boolean)
45692
+ : dataRoutes),
45672
45693
  ...(!isNextDataServerResolving
45673
45694
  ? [
45674
45695
  // ensure we 404 for non-existent _next/data routes before
@@ -45691,6 +45712,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
45691
45712
  'x-nextjs-matched-path': '/$1',
45692
45713
  },
45693
45714
  continue: true,
45715
+ override: true,
45694
45716
  },
45695
45717
  // add a catch-all data route so we don't 404 when getting
45696
45718
  // middleware effects
@@ -735,15 +735,15 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
735
735
  },
736
736
  ]
737
737
  : []),
738
- // ensure prerender's for notFound: true static routes
739
- // have 404 status code when not in preview mode
740
- ...notFoundPreviewRoutes,
741
738
  ...headers,
742
739
  ...redirects,
743
740
  // middleware comes directly after redirects but before
744
741
  // beforeFiles rewrites as middleware is not a "file" route
745
742
  ...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
746
743
  ...beforeFilesRewrites,
744
+ // ensure prerender's for notFound: true static routes
745
+ // have 404 status code when not in preview mode
746
+ ...notFoundPreviewRoutes,
747
747
  // Make sure to 404 for the /404 path itself
748
748
  ...(i18n
749
749
  ? [
@@ -832,7 +832,8 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
832
832
  check: true,
833
833
  dest: '$0',
834
834
  },
835
- // remove locale prefixes to check public files
835
+ // remove locale prefixes to check public files and
836
+ // to allow checking non-prefixed lambda outputs
836
837
  ...(i18n
837
838
  ? [
838
839
  {
@@ -844,26 +845,46 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
844
845
  },
845
846
  ]
846
847
  : []),
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
848
  // routes that are called after each rewrite or after routes
861
849
  // if there no rewrites
862
850
  { handle: 'rewrite' },
863
851
  // re-build /_next/data URL after resolving
864
852
  ...denormalizeNextDataRoute(),
853
+ ...(isNextDataServerResolving
854
+ ? dataRoutes.filter(route => {
855
+ // filter to only static data routes as dynamic routes will be handled
856
+ // below
857
+ const { pathname } = new URL(route.dest || '/', 'http://n');
858
+ return !(0, utils_1.isDynamicRoute)(pathname.replace(/\.json$/, ''));
859
+ })
860
+ : []),
865
861
  // /_next/data routes for getServerProps/getStaticProps pages
866
- ...dataRoutes,
862
+ ...(isNextDataServerResolving
863
+ ? // when resolving data routes for middleware we need to include
864
+ // all dynamic routes including non-SSG/SSP so that the priority
865
+ // is correct
866
+ dynamicRoutes
867
+ .map(route => {
868
+ route = Object.assign({}, route);
869
+ route.src = path_1.default.posix.join('^/', entryDirectory, '_next/data/', escapedBuildId, route.src.replace(/(^\^|\$$)/g, '') + '.json$');
870
+ const { pathname } = new URL(route.dest || '/', 'http://n');
871
+ let isPrerender = !!prerenders[path_1.default.join('./', pathname)];
872
+ if (routesManifest.i18n) {
873
+ for (const locale of routesManifest.i18n?.locales || []) {
874
+ const prerenderPathname = pathname.replace(/^\/\$nextLocale/, `/${locale}`);
875
+ if (prerenders[path_1.default.join('./', prerenderPathname)]) {
876
+ isPrerender = true;
877
+ break;
878
+ }
879
+ }
880
+ }
881
+ if (isPrerender) {
882
+ route.dest = `/_next/data/${buildId}${pathname}.json`;
883
+ }
884
+ return route;
885
+ })
886
+ .filter(Boolean)
887
+ : dataRoutes),
867
888
  ...(!isNextDataServerResolving
868
889
  ? [
869
890
  // ensure we 404 for non-existent _next/data routes before
@@ -886,6 +907,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
886
907
  'x-nextjs-matched-path': '/$1',
887
908
  },
888
909
  continue: true,
910
+ override: true,
889
911
  },
890
912
  // add a catch-all data route so we don't 404 when getting
891
913
  // middleware effects
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.1.11",
3
+ "version": "3.1.14",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -11,8 +11,7 @@
11
11
  "test-unit": "yarn test test/build.test.ts test/unit/",
12
12
  "test-next-local": "jest --env node --verbose --bail --forceExit --testTimeout=360000 test/integration/*.test.js test/integration/*.test.ts",
13
13
  "test-next-local:middleware": "jest --env node --verbose --bail --useStderr --testTimeout=360000 test/integration/middleware.test.ts",
14
- "test-integration-once": "rm test/builder-info.json; jest --env node --verbose --runInBand --bail test/fixtures/**/*.test.js",
15
- "prepublishOnly": "yarn build"
14
+ "test-integration-once": "rm test/builder-info.json; jest --env node --verbose --runInBand --bail test/fixtures/**/*.test.js"
16
15
  },
17
16
  "repository": {
18
17
  "type": "git",
@@ -45,9 +44,9 @@
45
44
  "@types/semver": "6.0.0",
46
45
  "@types/text-table": "0.2.1",
47
46
  "@types/webpack-sources": "3.2.0",
48
- "@vercel/build-utils": "5.0.7",
47
+ "@vercel/build-utils": "5.1.1",
49
48
  "@vercel/nft": "0.21.0",
50
- "@vercel/routing-utils": "2.0.0",
49
+ "@vercel/routing-utils": "2.0.1",
51
50
  "async-sema": "3.0.1",
52
51
  "buffer-crc32": "0.2.13",
53
52
  "cheerio": "1.0.0-rc.10",
@@ -70,5 +69,5 @@
70
69
  "typescript": "4.5.2",
71
70
  "webpack-sources": "3.2.3"
72
71
  },
73
- "gitHead": "e8c7db59cf2746422f1f7e14cc6b7f901c243d50"
72
+ "gitHead": "5eb8b16cbdf6215618b4b8125673941757fa1a8e"
74
73
  }