@vercel/next 3.8.5 → 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
@@ -43512,6 +43512,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
43512
43512
  initialPseudoLayerUncompressed: uncompressedInitialSize,
43513
43513
  lambdaCompressedByteLimit,
43514
43514
  internalPages,
43515
+ pageExtensions,
43515
43516
  });
43516
43517
  for (const group of apiLambdaGroups) {
43517
43518
  group.isApiLambda = true;
@@ -45107,9 +45108,20 @@ exports.getPrerenderManifest = getPrerenderManifest;
45107
45108
  let _usesSrcCache;
45108
45109
  async function usesSrcDirectory(workPath) {
45109
45110
  if (!_usesSrcCache) {
45110
- 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');
45111
45123
  try {
45112
- if ((await fs_extra_1.default.stat(source)).isDirectory()) {
45124
+ if ((await fs_extra_1.default.stat(sourceAppdir)).isDirectory()) {
45113
45125
  _usesSrcCache = true;
45114
45126
  }
45115
45127
  }
@@ -45120,12 +45132,11 @@ async function usesSrcDirectory(workPath) {
45120
45132
  return Boolean(_usesSrcCache);
45121
45133
  }
45122
45134
  async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
45123
- // TODO: this should be updated to get the pageExtensions
45124
- // value used during next build
45135
+ const usesSrcDir = await usesSrcDirectory(workPath);
45125
45136
  const extensionsToTry = pageExtensions || ['js', 'jsx', 'ts', 'tsx'];
45126
45137
  for (const pageType of ['pages', 'app']) {
45127
45138
  let fsPath = path_1.default.join(workPath, pageType, page);
45128
- if (await usesSrcDirectory(workPath)) {
45139
+ if (usesSrcDir) {
45129
45140
  fsPath = path_1.default.join(workPath, 'src', pageType, page);
45130
45141
  }
45131
45142
  if (fs_extra_1.default.existsSync(fsPath)) {
@@ -45134,19 +45145,38 @@ async function getSourceFilePathFromPage({ workPath, page, pageExtensions, }) {
45134
45145
  const extensionless = fsPath.replace(path_1.default.extname(fsPath), '');
45135
45146
  for (const ext of extensionsToTry) {
45136
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
+ }
45137
45154
  if (fs_extra_1.default.existsSync(fsPath)) {
45138
45155
  return path_1.default.relative(workPath, fsPath);
45139
45156
  }
45140
45157
  }
45141
45158
  if (isDirectory(extensionless)) {
45142
- for (const ext of extensionsToTry) {
45143
- fsPath = path_1.default.join(extensionless, `index.${ext}`);
45144
- if (fs_extra_1.default.existsSync(fsPath)) {
45145
- 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
+ }
45146
45165
  }
45147
- fsPath = path_1.default.join(extensionless, `route.${ext}`);
45148
- if (fs_extra_1.default.existsSync(fsPath)) {
45149
- 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
+ }
45150
45180
  }
45151
45181
  }
45152
45182
  }
@@ -45979,7 +46009,6 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
45979
46009
  ? normalizeRegions(edgeFunction.regions)
45980
46010
  : undefined,
45981
46011
  entrypoint: 'index.js',
45982
- envVarsInUse: edgeFunction.env,
45983
46012
  assets: (edgeFunction.assets ?? []).map(({ name }) => {
45984
46013
  return {
45985
46014
  name,
@@ -438,6 +438,7 @@ async function serverBuild({ dynamicPages, pagesDir, config = {}, privateOutputs
438
438
  initialPseudoLayerUncompressed: uncompressedInitialSize,
439
439
  lambdaCompressedByteLimit,
440
440
  internalPages,
441
+ pageExtensions,
441
442
  });
442
443
  for (const group of apiLambdaGroups) {
443
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.5",
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.3",
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",