@vercel/next 3.8.4 → 3.8.6

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
@@ -43257,14 +43257,12 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43257
43257
  if ((0, utils_1.isDynamicRoute)(normalizedPathname)) {
43258
43258
  dynamicPages.push(normalizedPathname);
43259
43259
  }
43260
- if (pageMatchesApi(page)) {
43261
- apiPages.push(page);
43262
- }
43263
- else if ((appPathRoutesManifest?.[`${normalizedPathname}/page`] ||
43264
- appPathRoutesManifest?.[`${normalizedPathname}/route`]) &&
43265
- lambdaAppPaths[page]) {
43260
+ if (lambdaAppPaths[page]) {
43266
43261
  appRouterPages.push(page);
43267
43262
  }
43263
+ else if (pageMatchesApi(page)) {
43264
+ apiPages.push(page);
43265
+ }
43268
43266
  else {
43269
43267
  nonApiPages.push(page);
43270
43268
  }
@@ -43514,6 +43512,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43514
43512
  initialPseudoLayerUncompressed: uncompressedInitialSize,
43515
43513
  lambdaCompressedByteLimit,
43516
43514
  internalPages,
43515
+ pageExtensions,
43517
43516
  });
43518
43517
  for (const group of apiLambdaGroups) {
43519
43518
  group.isApiLambda = true;
@@ -45109,9 +45108,20 @@ exports.getPrerenderManifest = getPrerenderManifest;
45109
45108
  let _usesSrcCache;
45110
45109
  async function usesSrcDirectory(workPath) {
45111
45110
  if (!_usesSrcCache) {
45112
- const source = path_1.default.join(workPath, 'src', 'pages');
45111
+ const sourcePages = path_1.default.join(workPath, 'src', 'pages');
45112
+ try {
45113
+ if ((await fs_extra_1.default.stat(sourcePages)).isDirectory()) {
45114
+ _usesSrcCache = true;
45115
+ }
45116
+ }
45117
+ catch (_err) {
45118
+ _usesSrcCache = false;
45119
+ }
45120
+ }
45121
+ if (!_usesSrcCache) {
45122
+ const sourceAppdir = path_1.default.join(workPath, 'src', 'app');
45113
45123
  try {
45114
- if ((await fs_extra_1.default.stat(source)).isDirectory()) {
45124
+ if ((await fs_extra_1.default.stat(sourceAppdir)).isDirectory()) {
45115
45125
  _usesSrcCache = true;
45116
45126
  }
45117
45127
  }
@@ -45122,12 +45132,11 @@ async function usesSrcDirectory(workPath) {
45122
45132
  return Boolean(_usesSrcCache);
45123
45133
  }
45124
45134
  async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
45125
- // TODO: this should be updated to get the pageExtensions
45126
- // value used during next build
45135
+ const usesSrcDir = await usesSrcDirectory(workPath);
45127
45136
  const extensionsToTry = pageExtensions || ['js', 'jsx', 'ts', 'tsx'];
45128
45137
  for (const pageType of ['pages', 'app']) {
45129
45138
  let fsPath = path_1.default.join(workPath, pageType, page);
45130
- if (await usesSrcDirectory(workPath)) {
45139
+ if (usesSrcDir) {
45131
45140
  fsPath = path_1.default.join(workPath, 'src', pageType, page);
45132
45141
  }
45133
45142
  if (fs_extra_1.default.existsSync(fsPath)) {
@@ -45136,19 +45145,38 @@ async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
45136
45145
  const extensionless = fsPath.replace(path_1.default.extname(fsPath), '');
45137
45146
  for (const ext of extensionsToTry) {
45138
45147
  fsPath = `${extensionless}.${ext}`;
45148
+ // for appDir, we need to treat "index.js" as root-level "page.js"
45149
+ if (pageType === 'app' &&
45150
+ extensionless ===
45151
+ path_1.default.join(workPath, `${usesSrcDir ? 'src/' : ''}app/index`)) {
45152
+ fsPath = `${extensionless.replace(/index$/, 'page')}.${ext}`;
45153
+ }
45139
45154
  if (fs_extra_1.default.existsSync(fsPath)) {
45140
45155
  return path_1.default.relative(workPath, fsPath);
45141
45156
  }
45142
45157
  }
45143
45158
  if (isDirectory(extensionless)) {
45144
- for (const ext of extensionsToTry) {
45145
- fsPath = path_1.default.join(extensionless, `index.${ext}`);
45146
- if (fs_extra_1.default.existsSync(fsPath)) {
45147
- return path_1.default.relative(workPath, fsPath);
45159
+ if (pageType === 'pages') {
45160
+ for (const ext of extensionsToTry) {
45161
+ fsPath = path_1.default.join(extensionless, `index.${ext}`);
45162
+ if (fs_extra_1.default.existsSync(fsPath)) {
45163
+ return path_1.default.relative(workPath, fsPath);
45164
+ }
45148
45165
  }
45149
- fsPath = path_1.default.join(extensionless, `route.${ext}`);
45150
- if (fs_extra_1.default.existsSync(fsPath)) {
45151
- return path_1.default.relative(workPath, fsPath);
45166
+ // appDir
45167
+ }
45168
+ else {
45169
+ for (const ext of extensionsToTry) {
45170
+ // RSC
45171
+ fsPath = path_1.default.join(extensionless, `page.${ext}`);
45172
+ if (fs_extra_1.default.existsSync(fsPath)) {
45173
+ return path_1.default.relative(workPath, fsPath);
45174
+ }
45175
+ // Route Handlers
45176
+ fsPath = path_1.default.join(extensionless, `route.${ext}`);
45177
+ if (fs_extra_1.default.existsSync(fsPath)) {
45178
+ return path_1.default.relative(workPath, fsPath);
45179
+ }
45152
45180
  }
45153
45181
  }
45154
45182
  }
@@ -45981,7 +46009,6 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
45981
46009
  ? normalizeRegions(edgeFunction.regions)
45982
46010
  : undefined,
45983
46011
  entrypoint: 'index.js',
45984
- envVarsInUse: edgeFunction.env,
45985
46012
  assets: (edgeFunction.assets ?? []).map(({ name }) => {
45986
46013
  return {
45987
46014
  name,
@@ -183,14 +183,12 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
183
183
  if ((0, utils_1.isDynamicRoute)(normalizedPathname)) {
184
184
  dynamicPages.push(normalizedPathname);
185
185
  }
186
- if (pageMatchesApi(page)) {
187
- apiPages.push(page);
188
- }
189
- else if ((appPathRoutesManifest?.[`${normalizedPathname}/page`] ||
190
- appPathRoutesManifest?.[`${normalizedPathname}/route`]) &&
191
- lambdaAppPaths[page]) {
186
+ if (lambdaAppPaths[page]) {
192
187
  appRouterPages.push(page);
193
188
  }
189
+ else if (pageMatchesApi(page)) {
190
+ apiPages.push(page);
191
+ }
194
192
  else {
195
193
  nonApiPages.push(page);
196
194
  }
@@ -440,6 +438,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
440
438
  initialPseudoLayerUncompressed: uncompressedInitialSize,
441
439
  lambdaCompressedByteLimit,
442
440
  internalPages,
441
+ pageExtensions,
443
442
  });
444
443
  for (const group of apiLambdaGroups) {
445
444
  group.isApiLambda = true;
package/dist/utils.js CHANGED
@@ -758,9 +758,20 @@ exports.getPrerenderManifest = getPrerenderManifest;
758
758
  let _usesSrcCache;
759
759
  async function usesSrcDirectory(workPath) {
760
760
  if (!_usesSrcCache) {
761
- const source = path_1.default.join(workPath, 'src', 'pages');
761
+ const sourcePages = path_1.default.join(workPath, 'src', 'pages');
762
762
  try {
763
- if ((await fs_extra_1.default.stat(source)).isDirectory()) {
763
+ if ((await fs_extra_1.default.stat(sourcePages)).isDirectory()) {
764
+ _usesSrcCache = true;
765
+ }
766
+ }
767
+ catch (_err) {
768
+ _usesSrcCache = false;
769
+ }
770
+ }
771
+ if (!_usesSrcCache) {
772
+ const sourceAppdir = path_1.default.join(workPath, 'src', 'app');
773
+ try {
774
+ if ((await fs_extra_1.default.stat(sourceAppdir)).isDirectory()) {
764
775
  _usesSrcCache = true;
765
776
  }
766
777
  }
@@ -771,12 +782,11 @@ async function usesSrcDirectory(workPath) {
771
782
  return Boolean(_usesSrcCache);
772
783
  }
773
784
  async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
774
- // TODO: this should be updated to get the pageExtensions
775
- // value used during next build
785
+ const usesSrcDir = await usesSrcDirectory(workPath);
776
786
  const extensionsToTry = pageExtensions || ['js', 'jsx', 'ts', 'tsx'];
777
787
  for (const pageType of ['pages', 'app']) {
778
788
  let fsPath = path_1.default.join(workPath, pageType, page);
779
- if (await usesSrcDirectory(workPath)) {
789
+ if (usesSrcDir) {
780
790
  fsPath = path_1.default.join(workPath, 'src', pageType, page);
781
791
  }
782
792
  if (fs_extra_1.default.existsSync(fsPath)) {
@@ -785,19 +795,38 @@ async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
785
795
  const extensionless = fsPath.replace(path_1.default.extname(fsPath), '');
786
796
  for (const ext of extensionsToTry) {
787
797
  fsPath = `${extensionless}.${ext}`;
798
+ // for appDir, we need to treat "index.js" as root-level "page.js"
799
+ if (pageType === 'app' &&
800
+ extensionless ===
801
+ path_1.default.join(workPath, `${usesSrcDir ? 'src/' : ''}app/index`)) {
802
+ fsPath = `${extensionless.replace(/index$/, 'page')}.${ext}`;
803
+ }
788
804
  if (fs_extra_1.default.existsSync(fsPath)) {
789
805
  return path_1.default.relative(workPath, fsPath);
790
806
  }
791
807
  }
792
808
  if (isDirectory(extensionless)) {
793
- for (const ext of extensionsToTry) {
794
- fsPath = path_1.default.join(extensionless, `index.${ext}`);
795
- if (fs_extra_1.default.existsSync(fsPath)) {
796
- return path_1.default.relative(workPath, fsPath);
809
+ if (pageType === 'pages') {
810
+ for (const ext of extensionsToTry) {
811
+ fsPath = path_1.default.join(extensionless, `index.${ext}`);
812
+ if (fs_extra_1.default.existsSync(fsPath)) {
813
+ return path_1.default.relative(workPath, fsPath);
814
+ }
797
815
  }
798
- fsPath = path_1.default.join(extensionless, `route.${ext}`);
799
- if (fs_extra_1.default.existsSync(fsPath)) {
800
- return path_1.default.relative(workPath, fsPath);
816
+ // appDir
817
+ }
818
+ else {
819
+ for (const ext of extensionsToTry) {
820
+ // RSC
821
+ fsPath = path_1.default.join(extensionless, `page.${ext}`);
822
+ if (fs_extra_1.default.existsSync(fsPath)) {
823
+ return path_1.default.relative(workPath, fsPath);
824
+ }
825
+ // Route Handlers
826
+ fsPath = path_1.default.join(extensionless, `route.${ext}`);
827
+ if (fs_extra_1.default.existsSync(fsPath)) {
828
+ return path_1.default.relative(workPath, fsPath);
829
+ }
801
830
  }
802
831
  }
803
832
  }
@@ -1630,7 +1659,6 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1630
1659
  ? normalizeRegions(edgeFunction.regions)
1631
1660
  : undefined,
1632
1661
  entrypoint: 'index.js',
1633
- envVarsInUse: edgeFunction.env,
1634
1662
  assets: (edgeFunction.assets ?? []).map(({ name }) => {
1635
1663
  return {
1636
1664
  name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.8.4",
3
+ "version": "3.8.6",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -26,7 +26,7 @@
26
26
  "@types/semver": "6.0.0",
27
27
  "@types/text-table": "0.2.1",
28
28
  "@types/webpack-sources": "3.2.0",
29
- "@vercel/build-utils": "6.7.2",
29
+ "@vercel/build-utils": "6.7.4",
30
30
  "@vercel/nft": "0.22.5",
31
31
  "@vercel/routing-utils": "2.2.1",
32
32
  "async-sema": "3.0.1",