@vercel/next 3.0.0 → 3.0.1-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 CHANGED
@@ -15907,214 +15907,6 @@ exports.getRoot = function getRoot(file) {
15907
15907
  };
15908
15908
 
15909
15909
 
15910
- /***/ }),
15911
-
15912
- /***/ 3197:
15913
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
15914
-
15915
- var concatMap = __webpack_require__(4527);
15916
- var balanced = __webpack_require__(3353);
15917
-
15918
- module.exports = expandTop;
15919
-
15920
- var escSlash = '\0SLASH'+Math.random()+'\0';
15921
- var escOpen = '\0OPEN'+Math.random()+'\0';
15922
- var escClose = '\0CLOSE'+Math.random()+'\0';
15923
- var escComma = '\0COMMA'+Math.random()+'\0';
15924
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
15925
-
15926
- function numeric(str) {
15927
- return parseInt(str, 10) == str
15928
- ? parseInt(str, 10)
15929
- : str.charCodeAt(0);
15930
- }
15931
-
15932
- function escapeBraces(str) {
15933
- return str.split('\\\\').join(escSlash)
15934
- .split('\\{').join(escOpen)
15935
- .split('\\}').join(escClose)
15936
- .split('\\,').join(escComma)
15937
- .split('\\.').join(escPeriod);
15938
- }
15939
-
15940
- function unescapeBraces(str) {
15941
- return str.split(escSlash).join('\\')
15942
- .split(escOpen).join('{')
15943
- .split(escClose).join('}')
15944
- .split(escComma).join(',')
15945
- .split(escPeriod).join('.');
15946
- }
15947
-
15948
-
15949
- // Basically just str.split(","), but handling cases
15950
- // where we have nested braced sections, which should be
15951
- // treated as individual members, like {a,{b,c},d}
15952
- function parseCommaParts(str) {
15953
- if (!str)
15954
- return [''];
15955
-
15956
- var parts = [];
15957
- var m = balanced('{', '}', str);
15958
-
15959
- if (!m)
15960
- return str.split(',');
15961
-
15962
- var pre = m.pre;
15963
- var body = m.body;
15964
- var post = m.post;
15965
- var p = pre.split(',');
15966
-
15967
- p[p.length-1] += '{' + body + '}';
15968
- var postParts = parseCommaParts(post);
15969
- if (post.length) {
15970
- p[p.length-1] += postParts.shift();
15971
- p.push.apply(p, postParts);
15972
- }
15973
-
15974
- parts.push.apply(parts, p);
15975
-
15976
- return parts;
15977
- }
15978
-
15979
- function expandTop(str) {
15980
- if (!str)
15981
- return [];
15982
-
15983
- // I don't know why Bash 4.3 does this, but it does.
15984
- // Anything starting with {} will have the first two bytes preserved
15985
- // but *only* at the top level, so {},a}b will not expand to anything,
15986
- // but a{},b}c will be expanded to [a}c,abc].
15987
- // One could argue that this is a bug in Bash, but since the goal of
15988
- // this module is to match Bash's rules, we escape a leading {}
15989
- if (str.substr(0, 2) === '{}') {
15990
- str = '\\{\\}' + str.substr(2);
15991
- }
15992
-
15993
- return expand(escapeBraces(str), true).map(unescapeBraces);
15994
- }
15995
-
15996
- function identity(e) {
15997
- return e;
15998
- }
15999
-
16000
- function embrace(str) {
16001
- return '{' + str + '}';
16002
- }
16003
- function isPadded(el) {
16004
- return /^-?0\d/.test(el);
16005
- }
16006
-
16007
- function lte(i, y) {
16008
- return i <= y;
16009
- }
16010
- function gte(i, y) {
16011
- return i >= y;
16012
- }
16013
-
16014
- function expand(str, isTop) {
16015
- var expansions = [];
16016
-
16017
- var m = balanced('{', '}', str);
16018
- if (!m || /\$$/.test(m.pre)) return [str];
16019
-
16020
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
16021
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
16022
- var isSequence = isNumericSequence || isAlphaSequence;
16023
- var isOptions = m.body.indexOf(',') >= 0;
16024
- if (!isSequence && !isOptions) {
16025
- // {a},b}
16026
- if (m.post.match(/,.*\}/)) {
16027
- str = m.pre + '{' + m.body + escClose + m.post;
16028
- return expand(str);
16029
- }
16030
- return [str];
16031
- }
16032
-
16033
- var n;
16034
- if (isSequence) {
16035
- n = m.body.split(/\.\./);
16036
- } else {
16037
- n = parseCommaParts(m.body);
16038
- if (n.length === 1) {
16039
- // x{{a,b}}y ==> x{a}y x{b}y
16040
- n = expand(n[0], false).map(embrace);
16041
- if (n.length === 1) {
16042
- var post = m.post.length
16043
- ? expand(m.post, false)
16044
- : [''];
16045
- return post.map(function(p) {
16046
- return m.pre + n[0] + p;
16047
- });
16048
- }
16049
- }
16050
- }
16051
-
16052
- // at this point, n is the parts, and we know it's not a comma set
16053
- // with a single entry.
16054
-
16055
- // no need to expand pre, since it is guaranteed to be free of brace-sets
16056
- var pre = m.pre;
16057
- var post = m.post.length
16058
- ? expand(m.post, false)
16059
- : [''];
16060
-
16061
- var N;
16062
-
16063
- if (isSequence) {
16064
- var x = numeric(n[0]);
16065
- var y = numeric(n[1]);
16066
- var width = Math.max(n[0].length, n[1].length)
16067
- var incr = n.length == 3
16068
- ? Math.abs(numeric(n[2]))
16069
- : 1;
16070
- var test = lte;
16071
- var reverse = y < x;
16072
- if (reverse) {
16073
- incr *= -1;
16074
- test = gte;
16075
- }
16076
- var pad = n.some(isPadded);
16077
-
16078
- N = [];
16079
-
16080
- for (var i = x; test(i, y); i += incr) {
16081
- var c;
16082
- if (isAlphaSequence) {
16083
- c = String.fromCharCode(i);
16084
- if (c === '\\')
16085
- c = '';
16086
- } else {
16087
- c = String(i);
16088
- if (pad) {
16089
- var need = width - c.length;
16090
- if (need > 0) {
16091
- var z = new Array(need + 1).join('0');
16092
- if (i < 0)
16093
- c = '-' + z + c.slice(1);
16094
- else
16095
- c = z + c;
16096
- }
16097
- }
16098
- }
16099
- N.push(c);
16100
- }
16101
- } else {
16102
- N = concatMap(n, function(el) { return expand(el, false) });
16103
- }
16104
-
16105
- for (var j = 0; j < N.length; j++) {
16106
- for (var k = 0; k < post.length; k++) {
16107
- var expansion = pre + N[j] + post[k];
16108
- if (!isTop || isSequence || expansion)
16109
- expansions.push(expansion);
16110
- }
16111
- }
16112
-
16113
- return expansions;
16114
- }
16115
-
16116
-
16117
-
16118
15910
  /***/ }),
16119
15911
 
16120
15912
  /***/ 538:
@@ -22714,7 +22506,7 @@ try {
22714
22506
  } catch (er) {}
22715
22507
 
22716
22508
  var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
22717
- var expand = __webpack_require__(3197)
22509
+ var expand = __webpack_require__(1561)
22718
22510
 
22719
22511
  var plTypes = {
22720
22512
  '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
@@ -23630,6 +23422,214 @@ function regExpEscape (s) {
23630
23422
  }
23631
23423
 
23632
23424
 
23425
+ /***/ }),
23426
+
23427
+ /***/ 1561:
23428
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
23429
+
23430
+ var concatMap = __webpack_require__(4527);
23431
+ var balanced = __webpack_require__(3353);
23432
+
23433
+ module.exports = expandTop;
23434
+
23435
+ var escSlash = '\0SLASH'+Math.random()+'\0';
23436
+ var escOpen = '\0OPEN'+Math.random()+'\0';
23437
+ var escClose = '\0CLOSE'+Math.random()+'\0';
23438
+ var escComma = '\0COMMA'+Math.random()+'\0';
23439
+ var escPeriod = '\0PERIOD'+Math.random()+'\0';
23440
+
23441
+ function numeric(str) {
23442
+ return parseInt(str, 10) == str
23443
+ ? parseInt(str, 10)
23444
+ : str.charCodeAt(0);
23445
+ }
23446
+
23447
+ function escapeBraces(str) {
23448
+ return str.split('\\\\').join(escSlash)
23449
+ .split('\\{').join(escOpen)
23450
+ .split('\\}').join(escClose)
23451
+ .split('\\,').join(escComma)
23452
+ .split('\\.').join(escPeriod);
23453
+ }
23454
+
23455
+ function unescapeBraces(str) {
23456
+ return str.split(escSlash).join('\\')
23457
+ .split(escOpen).join('{')
23458
+ .split(escClose).join('}')
23459
+ .split(escComma).join(',')
23460
+ .split(escPeriod).join('.');
23461
+ }
23462
+
23463
+
23464
+ // Basically just str.split(","), but handling cases
23465
+ // where we have nested braced sections, which should be
23466
+ // treated as individual members, like {a,{b,c},d}
23467
+ function parseCommaParts(str) {
23468
+ if (!str)
23469
+ return [''];
23470
+
23471
+ var parts = [];
23472
+ var m = balanced('{', '}', str);
23473
+
23474
+ if (!m)
23475
+ return str.split(',');
23476
+
23477
+ var pre = m.pre;
23478
+ var body = m.body;
23479
+ var post = m.post;
23480
+ var p = pre.split(',');
23481
+
23482
+ p[p.length-1] += '{' + body + '}';
23483
+ var postParts = parseCommaParts(post);
23484
+ if (post.length) {
23485
+ p[p.length-1] += postParts.shift();
23486
+ p.push.apply(p, postParts);
23487
+ }
23488
+
23489
+ parts.push.apply(parts, p);
23490
+
23491
+ return parts;
23492
+ }
23493
+
23494
+ function expandTop(str) {
23495
+ if (!str)
23496
+ return [];
23497
+
23498
+ // I don't know why Bash 4.3 does this, but it does.
23499
+ // Anything starting with {} will have the first two bytes preserved
23500
+ // but *only* at the top level, so {},a}b will not expand to anything,
23501
+ // but a{},b}c will be expanded to [a}c,abc].
23502
+ // One could argue that this is a bug in Bash, but since the goal of
23503
+ // this module is to match Bash's rules, we escape a leading {}
23504
+ if (str.substr(0, 2) === '{}') {
23505
+ str = '\\{\\}' + str.substr(2);
23506
+ }
23507
+
23508
+ return expand(escapeBraces(str), true).map(unescapeBraces);
23509
+ }
23510
+
23511
+ function identity(e) {
23512
+ return e;
23513
+ }
23514
+
23515
+ function embrace(str) {
23516
+ return '{' + str + '}';
23517
+ }
23518
+ function isPadded(el) {
23519
+ return /^-?0\d/.test(el);
23520
+ }
23521
+
23522
+ function lte(i, y) {
23523
+ return i <= y;
23524
+ }
23525
+ function gte(i, y) {
23526
+ return i >= y;
23527
+ }
23528
+
23529
+ function expand(str, isTop) {
23530
+ var expansions = [];
23531
+
23532
+ var m = balanced('{', '}', str);
23533
+ if (!m || /\$$/.test(m.pre)) return [str];
23534
+
23535
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
23536
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
23537
+ var isSequence = isNumericSequence || isAlphaSequence;
23538
+ var isOptions = m.body.indexOf(',') >= 0;
23539
+ if (!isSequence && !isOptions) {
23540
+ // {a},b}
23541
+ if (m.post.match(/,.*\}/)) {
23542
+ str = m.pre + '{' + m.body + escClose + m.post;
23543
+ return expand(str);
23544
+ }
23545
+ return [str];
23546
+ }
23547
+
23548
+ var n;
23549
+ if (isSequence) {
23550
+ n = m.body.split(/\.\./);
23551
+ } else {
23552
+ n = parseCommaParts(m.body);
23553
+ if (n.length === 1) {
23554
+ // x{{a,b}}y ==> x{a}y x{b}y
23555
+ n = expand(n[0], false).map(embrace);
23556
+ if (n.length === 1) {
23557
+ var post = m.post.length
23558
+ ? expand(m.post, false)
23559
+ : [''];
23560
+ return post.map(function(p) {
23561
+ return m.pre + n[0] + p;
23562
+ });
23563
+ }
23564
+ }
23565
+ }
23566
+
23567
+ // at this point, n is the parts, and we know it's not a comma set
23568
+ // with a single entry.
23569
+
23570
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
23571
+ var pre = m.pre;
23572
+ var post = m.post.length
23573
+ ? expand(m.post, false)
23574
+ : [''];
23575
+
23576
+ var N;
23577
+
23578
+ if (isSequence) {
23579
+ var x = numeric(n[0]);
23580
+ var y = numeric(n[1]);
23581
+ var width = Math.max(n[0].length, n[1].length)
23582
+ var incr = n.length == 3
23583
+ ? Math.abs(numeric(n[2]))
23584
+ : 1;
23585
+ var test = lte;
23586
+ var reverse = y < x;
23587
+ if (reverse) {
23588
+ incr *= -1;
23589
+ test = gte;
23590
+ }
23591
+ var pad = n.some(isPadded);
23592
+
23593
+ N = [];
23594
+
23595
+ for (var i = x; test(i, y); i += incr) {
23596
+ var c;
23597
+ if (isAlphaSequence) {
23598
+ c = String.fromCharCode(i);
23599
+ if (c === '\\')
23600
+ c = '';
23601
+ } else {
23602
+ c = String(i);
23603
+ if (pad) {
23604
+ var need = width - c.length;
23605
+ if (need > 0) {
23606
+ var z = new Array(need + 1).join('0');
23607
+ if (i < 0)
23608
+ c = '-' + z + c.slice(1);
23609
+ else
23610
+ c = z + c;
23611
+ }
23612
+ }
23613
+ }
23614
+ N.push(c);
23615
+ }
23616
+ } else {
23617
+ N = concatMap(n, function(el) { return expand(el, false) });
23618
+ }
23619
+
23620
+ for (var j = 0; j < N.length; j++) {
23621
+ for (var k = 0; k < post.length; k++) {
23622
+ var expansion = pre + N[j] + post[k];
23623
+ if (!isTop || isSequence || expansion)
23624
+ expansions.push(expansion);
23625
+ }
23626
+ }
23627
+
23628
+ return expansions;
23629
+ }
23630
+
23631
+
23632
+
23633
23633
  /***/ }),
23634
23634
 
23635
23635
  /***/ 3277:
@@ -47010,6 +47010,7 @@ const escape_string_regexp_1 = __importDefault(__webpack_require__(1426));
47010
47010
  const pretty_bytes_1 = __importDefault(__webpack_require__(539));
47011
47011
  // related PR: https://github.com/vercel/next.js/pull/30046
47012
47012
  const CORRECT_NOT_FOUND_ROUTES_VERSION = 'v12.0.1';
47013
+ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
47013
47014
  async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
47014
47015
  const lambdas = {};
47015
47016
  const prerenders = {};
@@ -47017,6 +47018,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
47017
47018
  const internalPages = ['_app.js', '_error.js', '_document.js'];
47018
47019
  const pageBuildTraces = await (0, build_utils_1.glob)('**/*.js.nft.json', pagesDir);
47019
47020
  const isCorrectNotFoundRoutes = semver_1.default.gte(nextVersion, CORRECT_NOT_FOUND_ROUTES_VERSION);
47021
+ const isCorrectMiddlewareOrder = semver_1.default.gte(nextVersion, CORRECT_MIDDLEWARE_ORDER_VERSION);
47020
47022
  let hasStatic500 = !!staticPages[path_1.default.join(entryDirectory, '500')];
47021
47023
  if (lambdaPageKeys.length === 0) {
47022
47024
  throw new build_utils_1.NowBuildError({
@@ -47406,6 +47408,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
47406
47408
  entryPath,
47407
47409
  outputDirectory,
47408
47410
  routesManifest,
47411
+ isCorrectMiddlewareOrder,
47409
47412
  });
47410
47413
  const dynamicRoutes = await (0, utils_1.getDynamicRoutes)(entryPath, entryDirectory, dynamicPages, false, routesManifest, omittedPrerenderRoutes, canUsePreviewMode, prerenderManifest.bypassToken || '', true, middleware.dynamicRouteMap).then(arr => (0, utils_1.localizeDynamicRoutes)(arr, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, true, isCorrectLocaleAPIRoutes));
47411
47414
  const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await (0, utils_1.getStaticFiles)(entryPath, entryDirectory, outputDirectory);
@@ -47572,6 +47575,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
47572
47575
  ...notFoundPreviewRoutes,
47573
47576
  ...headers,
47574
47577
  ...redirects,
47578
+ // middleware comes directly after redirects but before
47579
+ // beforeFiles rewrites as middleware is not a "file" route
47580
+ ...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
47575
47581
  ...beforeFilesRewrites,
47576
47582
  // Make sure to 404 for the /404 path itself
47577
47583
  ...(i18n
@@ -47611,7 +47617,10 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
47611
47617
  continue: true,
47612
47618
  },
47613
47619
  ]),
47614
- ...middleware.staticRoutes,
47620
+ // while middleware was in beta the order came right before
47621
+ // handle: 'filesystem' we maintain this for older versions
47622
+ // to prevent a local/deploy mismatch
47623
+ ...(!isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
47615
47624
  // Next.js page lambdas, `static/` folder, reserved assets, and `public/`
47616
47625
  // folder
47617
47626
  { handle: 'filesystem' },
@@ -49223,7 +49232,7 @@ async function getPrivateOutputs(dir, entries) {
49223
49232
  return { files, routes };
49224
49233
  }
49225
49234
  exports.getPrivateOutputs = getPrivateOutputs;
49226
- async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, }) {
49235
+ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, isCorrectMiddlewareOrder, }) {
49227
49236
  const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
49228
49237
  if (middlewareManifest && middlewareManifest?.sortedMiddleware.length > 0) {
49229
49238
  const workerConfigs = await Promise.all(middlewareManifest.sortedMiddleware.map(async (key) => {
@@ -49293,10 +49302,12 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
49293
49302
  source.edgeFunctions[edgeFile] = worker.edgeFunction;
49294
49303
  const route = {
49295
49304
  continue: true,
49296
- override: true,
49297
49305
  middlewarePath: edgeFile,
49298
49306
  src: worker.routeSrc,
49299
49307
  };
49308
+ if (isCorrectMiddlewareOrder) {
49309
+ route.override = true;
49310
+ }
49300
49311
  if (routesManifest.version > 3 && isDynamicRoute(worker.page)) {
49301
49312
  source.dynamicRouteMap.set(worker.page, route);
49302
49313
  }
@@ -17,6 +17,7 @@ const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
17
17
  const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
18
18
  // related PR: https://github.com/vercel/next.js/pull/30046
19
19
  const CORRECT_NOT_FOUND_ROUTES_VERSION = 'v12.0.1';
20
+ const CORRECT_MIDDLEWARE_ORDER_VERSION = 'v12.1.7-canary.29';
20
21
  async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs, baseDir, workPath, entryPath, nodeVersion, escapedBuildId, dynamicPrefix, entryDirectory, outputDirectory, redirects, beforeFilesRewrites, afterFilesRewrites, fallbackRewrites, headers, dataRoutes, hasIsr404Page, imagesManifest, wildcardConfig, routesManifest, staticPages, lambdaPages, nextVersion, canUsePreviewMode, prerenderManifest, omittedPrerenderRoutes, trailingSlashRedirects, isCorrectLocaleAPIRoutes, lambdaCompressedByteLimit, requiredServerFilesManifest, }) {
21
22
  const lambdas = {};
22
23
  const prerenders = {};
@@ -24,6 +25,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
24
25
  const internalPages = ['_app.js', '_error.js', '_document.js'];
25
26
  const pageBuildTraces = await (0, build_utils_1.glob)('**/*.js.nft.json', pagesDir);
26
27
  const isCorrectNotFoundRoutes = semver_1.default.gte(nextVersion, CORRECT_NOT_FOUND_ROUTES_VERSION);
28
+ const isCorrectMiddlewareOrder = semver_1.default.gte(nextVersion, CORRECT_MIDDLEWARE_ORDER_VERSION);
27
29
  let hasStatic500 = !!staticPages[path_1.default.join(entryDirectory, '500')];
28
30
  if (lambdaPageKeys.length === 0) {
29
31
  throw new build_utils_1.NowBuildError({
@@ -413,6 +415,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
413
415
  entryPath,
414
416
  outputDirectory,
415
417
  routesManifest,
418
+ isCorrectMiddlewareOrder,
416
419
  });
417
420
  const dynamicRoutes = await (0, utils_1.getDynamicRoutes)(entryPath, entryDirectory, dynamicPages, false, routesManifest, omittedPrerenderRoutes, canUsePreviewMode, prerenderManifest.bypassToken || '', true, middleware.dynamicRouteMap).then(arr => (0, utils_1.localizeDynamicRoutes)(arr, dynamicPrefix, entryDirectory, staticPages, prerenderManifest, routesManifest, true, isCorrectLocaleAPIRoutes));
418
421
  const { staticFiles, publicDirectoryFiles, staticDirectoryFiles } = await (0, utils_1.getStaticFiles)(entryPath, entryDirectory, outputDirectory);
@@ -579,6 +582,9 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
579
582
  ...notFoundPreviewRoutes,
580
583
  ...headers,
581
584
  ...redirects,
585
+ // middleware comes directly after redirects but before
586
+ // beforeFiles rewrites as middleware is not a "file" route
587
+ ...(isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
582
588
  ...beforeFilesRewrites,
583
589
  // Make sure to 404 for the /404 path itself
584
590
  ...(i18n
@@ -618,7 +624,10 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
618
624
  continue: true,
619
625
  },
620
626
  ]),
621
- ...middleware.staticRoutes,
627
+ // while middleware was in beta the order came right before
628
+ // handle: 'filesystem' we maintain this for older versions
629
+ // to prevent a local/deploy mismatch
630
+ ...(!isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
622
631
  // Next.js page lambdas, `static/` folder, reserved assets, and `public/`
623
632
  // folder
624
633
  { handle: 'filesystem' },
package/dist/utils.js CHANGED
@@ -1334,7 +1334,7 @@ async function getPrivateOutputs(dir, entries) {
1334
1334
  return { files, routes };
1335
1335
  }
1336
1336
  exports.getPrivateOutputs = getPrivateOutputs;
1337
- async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, }) {
1337
+ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest, isCorrectMiddlewareOrder, }) {
1338
1338
  const middlewareManifest = await getMiddlewareManifest(entryPath, outputDirectory);
1339
1339
  if (middlewareManifest && middlewareManifest?.sortedMiddleware.length > 0) {
1340
1340
  const workerConfigs = await Promise.all(middlewareManifest.sortedMiddleware.map(async (key) => {
@@ -1404,10 +1404,12 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1404
1404
  source.edgeFunctions[edgeFile] = worker.edgeFunction;
1405
1405
  const route = {
1406
1406
  continue: true,
1407
- override: true,
1408
1407
  middlewarePath: edgeFile,
1409
1408
  src: worker.routeSrc,
1410
1409
  };
1410
+ if (isCorrectMiddlewareOrder) {
1411
+ route.override = true;
1412
+ }
1411
1413
  if (routesManifest.version > 3 && isDynamicRoute(worker.page)) {
1412
1414
  source.dynamicRouteMap.set(worker.page, route);
1413
1415
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.0.0",
3
+ "version": "3.0.1-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": "4.0.0",
48
+ "@vercel/build-utils": "4.0.1-canary.0",
49
49
  "@vercel/nft": "0.19.1",
50
50
  "@vercel/routing-utils": "1.13.4",
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": "de0d2fba0b32588726a2799015eaff4e6bb65ffb"
73
+ "gitHead": "39f758662131ec37c467ebba5d5b618cba0c753f"
74
74
  }