@vercel/next 3.1.22 → 3.1.25

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
@@ -12930,15 +12930,12 @@ class Job {
12930
12930
  return;
12931
12931
  if (path.endsWith('.node'))
12932
12932
  return await sharedlib_emit_1.sharedLibEmit(path, this);
12933
- const handlePjsonBoundary = async (item) => {
12934
- // js files require the "type": "module" lookup, so always emit the package.json
12935
- if (item.endsWith(".js")) {
12936
- const pjsonBoundary = await this.getPjsonBoundary(item);
12937
- if (pjsonBoundary)
12938
- await this.emitFile(pjsonBoundary + path_1.sep + "package.json", "resolve", item);
12939
- }
12940
- };
12941
- await handlePjsonBoundary(path);
12933
+ // js files require the "type": "module" lookup, so always emit the package.json
12934
+ if (path.endsWith('.js')) {
12935
+ const pjsonBoundary = await this.getPjsonBoundary(path);
12936
+ if (pjsonBoundary)
12937
+ await this.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', path);
12938
+ }
12942
12939
  let analyzeResult;
12943
12940
  const cachedAnalysis = this.analysisCache.get(path);
12944
12941
  if (cachedAnalysis) {
@@ -12959,8 +12956,12 @@ class Job {
12959
12956
  this.esmFileList.add(path_1.relative(this.base, path));
12960
12957
  await Promise.all([
12961
12958
  ...[...assets].map(async (asset) => {
12962
- await handlePjsonBoundary(asset);
12963
- await this.emitFile(asset, 'asset', path);
12959
+ const ext = path_1.extname(asset);
12960
+ if (ext === '.js' || ext === '.mjs' || ext === '.node' || ext === '' ||
12961
+ this.ts && (ext === '.ts' || ext === '.tsx') && asset.startsWith(this.base) && asset.slice(this.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1)
12962
+ await this.emitDependency(asset, path);
12963
+ else
12964
+ await this.emitFile(asset, 'asset', path);
12964
12965
  }),
12965
12966
  ...[...deps].map(async (dep) => {
12966
12967
  try {
@@ -44471,7 +44472,7 @@ async function getServerlessPages(params) {
44471
44472
  const normalizedAppPaths = {};
44472
44473
  if (params.appPathRoutesManifest) {
44473
44474
  for (const [entry, normalizedEntry] of Object.entries(params.appPathRoutesManifest)) {
44474
- const normalizedPath = `${path_1.default.join('.', normalizedEntry)}.js`;
44475
+ const normalizedPath = `${path_1.default.join('.', normalizedEntry === '/' ? '/index' : normalizedEntry)}.js`;
44475
44476
  const globPath = `${path_1.default.join('.', entry)}.js`;
44476
44477
  if (appPaths[globPath]) {
44477
44478
  normalizedAppPaths[normalizedPath] = appPaths[globPath];
@@ -47452,7 +47453,22 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
47452
47453
  };
47453
47454
  for (const worker of workerConfigs.values()) {
47454
47455
  const edgeFile = worker.edgeFunction.name;
47455
- const shortPath = edgeFile.replace(/^pages\//, '');
47456
+ let shortPath = edgeFile;
47457
+ // Replacing the folder prefix for the page
47458
+ //
47459
+ // For `pages/`, use file base name directly:
47460
+ // pages/index -> index
47461
+ // For `app/`, use folder name, handle the root page as index:
47462
+ // app/route/page -> route
47463
+ // app/page -> index
47464
+ // app/index/page -> index/index
47465
+ if (shortPath.startsWith('pages/')) {
47466
+ shortPath = shortPath.replace(/^pages\//, '');
47467
+ }
47468
+ else if (shortPath.startsWith('app/') && shortPath.endsWith('/page')) {
47469
+ shortPath =
47470
+ shortPath.replace(/^app\//, '').replace(/(^|\/)page$/, '') || 'index';
47471
+ }
47456
47472
  worker.edgeFunction.name = shortPath;
47457
47473
  source.edgeFunctions[shortPath] = worker.edgeFunction;
47458
47474
  // we don't add the route for edge functions as these
package/dist/utils.js CHANGED
@@ -1454,7 +1454,22 @@ async function getMiddlewareBundle({ entryPath, outputDirectory, routesManifest,
1454
1454
  };
1455
1455
  for (const worker of workerConfigs.values()) {
1456
1456
  const edgeFile = worker.edgeFunction.name;
1457
- const shortPath = edgeFile.replace(/^pages\//, '');
1457
+ let shortPath = edgeFile;
1458
+ // Replacing the folder prefix for the page
1459
+ //
1460
+ // For `pages/`, use file base name directly:
1461
+ // pages/index -> index
1462
+ // For `app/`, use folder name, handle the root page as index:
1463
+ // app/route/page -> route
1464
+ // app/page -> index
1465
+ // app/index/page -> index/index
1466
+ if (shortPath.startsWith('pages/')) {
1467
+ shortPath = shortPath.replace(/^pages\//, '');
1468
+ }
1469
+ else if (shortPath.startsWith('app/') && shortPath.endsWith('/page')) {
1470
+ shortPath =
1471
+ shortPath.replace(/^app\//, '').replace(/(^|\/)page$/, '') || 'index';
1472
+ }
1458
1473
  worker.edgeFunction.name = shortPath;
1459
1474
  source.edgeFunctions[shortPath] = worker.edgeFunction;
1460
1475
  // we don't add the route for edge functions as these
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.1.22",
3
+ "version": "3.1.25",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -44,8 +44,8 @@
44
44
  "@types/semver": "6.0.0",
45
45
  "@types/text-table": "0.2.1",
46
46
  "@types/webpack-sources": "3.2.0",
47
- "@vercel/build-utils": "5.4.0",
48
- "@vercel/nft": "0.22.0",
47
+ "@vercel/build-utils": "5.4.2",
48
+ "@vercel/nft": "0.22.1",
49
49
  "@vercel/routing-utils": "2.0.2",
50
50
  "async-sema": "3.0.1",
51
51
  "buffer-crc32": "0.2.13",
@@ -69,5 +69,5 @@
69
69
  "typescript": "4.5.2",
70
70
  "webpack-sources": "3.2.3"
71
71
  },
72
- "gitHead": "e7e0a55b72bc73c26661f7b2a3caa0884a5d1764"
72
+ "gitHead": "d5537500d8957985c1ffb3798659a611cc2e5d5d"
73
73
  }