@next-community/adapter-vercel 0.0.1-beta.23 → 0.0.1-beta.24

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
@@ -9665,7 +9665,7 @@ async function handleStaticOutputs(outputs, {
9665
9665
  const srcExtension = import_node_path.default.extname(output.filePath);
9666
9666
  const isHtml = srcExtension === ".html";
9667
9667
  if (isHtml) {
9668
- vercelConfig2.overrides[import_node_path.default.posix.join("./", output.pathname + ".html")] = {
9668
+ vercelConfig2.overrides[import_node_path.default.posix.join("./", `${output.pathname}.html`)] = {
9669
9669
  contentType: "text/html; charset=utf-8",
9670
9670
  path: import_node_path.default.posix.join("./", output.pathname)
9671
9671
  };
@@ -9856,6 +9856,7 @@ async function handleNodeOutputs(nodeOutputs, {
9856
9856
  nextEnvLoaderPath
9857
9857
  );
9858
9858
  }
9859
+ const usesSrcDir = await usesSrcDirectory(projectDir);
9859
9860
  await Promise.all(
9860
9861
  nodeOutputs.map(async (output) => {
9861
9862
  await fsSema.acquire();
@@ -9918,7 +9919,8 @@ async function handleNodeOutputs(nodeOutputs, {
9918
9919
  const sourceFile = await getSourceFilePathFromPage({
9919
9920
  workPath: projectDir,
9920
9921
  page: output.sourcePage,
9921
- pageExtensions: config.pageExtensions || []
9922
+ pageExtensions: config.pageExtensions || [],
9923
+ usesSrcDir
9922
9924
  });
9923
9925
  const vercelConfigOpts = await (0, import_build_utils.getLambdaOptionsFromFunction)({
9924
9926
  sourceFile,
@@ -10229,42 +10231,29 @@ async function handleMiddleware(output, ctx) {
10229
10231
  }
10230
10232
  return routes;
10231
10233
  }
10232
- var _usesSrcCache;
10233
10234
  async function usesSrcDirectory(workPath) {
10234
- if (_usesSrcCache === void 0) {
10235
- const sourcePages = import_node_path.default.join(workPath, "src", "pages");
10236
- try {
10237
- if ((await import_promises.default.stat(sourcePages)).isDirectory()) {
10238
- _usesSrcCache = true;
10239
- }
10240
- } catch (_err) {
10241
- _usesSrcCache = false;
10242
- }
10243
- }
10244
- if (_usesSrcCache === void 0) {
10245
- const sourceAppdir = import_node_path.default.join(workPath, "src", "app");
10235
+ for (const dir of [
10236
+ import_node_path.default.join(workPath, "src", "pages"),
10237
+ import_node_path.default.join(workPath, "src", "app")
10238
+ ]) {
10246
10239
  try {
10247
- if ((await import_promises.default.stat(sourceAppdir)).isDirectory()) {
10248
- _usesSrcCache = true;
10240
+ if ((await import_promises.default.stat(dir)).isDirectory()) {
10241
+ return true;
10249
10242
  }
10250
10243
  } catch (_err) {
10251
- _usesSrcCache = false;
10252
10244
  }
10253
10245
  }
10254
- if (_usesSrcCache === void 0) {
10255
- _usesSrcCache = false;
10256
- }
10257
- return _usesSrcCache;
10246
+ return false;
10258
10247
  }
10259
10248
  function isDirectory(path3) {
10260
- return import_fs_extra3.default.existsSync(path3) && import_fs_extra3.default.lstatSync(path3).isDirectory();
10249
+ return import_fs_extra3.default.lstatSync(path3, { throwIfNoEntry: false })?.isDirectory() ?? false;
10261
10250
  }
10262
10251
  async function getSourceFilePathFromPage({
10263
10252
  workPath,
10264
10253
  page,
10265
- pageExtensions
10254
+ pageExtensions,
10255
+ usesSrcDir
10266
10256
  }) {
10267
- const usesSrcDir = await usesSrcDirectory(workPath);
10268
10257
  const extensionsToTry = pageExtensions || ["js", "jsx", "ts", "tsx"];
10269
10258
  for (const pageType of [
10270
10259
  // middleware is not nested in pages/app
@@ -10379,10 +10368,10 @@ function modifyWithRewriteHeaders(rewrites, {
10379
10368
  rewrite.headers = {
10380
10369
  ...rewrite.headers,
10381
10370
  ...pathname ? {
10382
- ["x-nextjs-rewritten-path"]: pathname
10371
+ "x-nextjs-rewritten-path": pathname
10383
10372
  } : {},
10384
10373
  ...query ? {
10385
- ["x-nextjs-rewritten-query"]: query
10374
+ "x-nextjs-rewritten-query": query
10386
10375
  } : {}
10387
10376
  };
10388
10377
  }
@@ -43,7 +43,7 @@ const getHandlerSource = (ctx) => `
43
43
  return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
44
44
  }
45
45
  return async function handler(request) {
46
- let middlewareHandler = await require("./" + path.posix.join(relativeDistDir, "server", "middleware.js"));
46
+ let middlewareHandler = await require(`./${path.posix.join(relativeDistDir, "server", "middleware.js")}`);
47
47
  middlewareHandler = middlewareHandler.handler || middlewareHandler;
48
48
  const context = getRequestContext();
49
49
  const response = await middlewareHandler(request, {
@@ -65,7 +65,7 @@ const getHandlerSource = (ctx) => `
65
65
  dynamicRoutes: dynamicRoutesRaw,
66
66
  staticRoutes: staticRoutesRaw,
67
67
  i18n
68
- } = require("./" + path.posix.join(relativeDistDir, "routes-manifest.json"));
68
+ } = require(`./${path.posix.join(relativeDistDir, "routes-manifest.json")}`);
69
69
  const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g;
70
70
  function escapeStringRegexp(str) {
71
71
  return str.replace(matchOperatorsRegex, "\\$&");
@@ -79,9 +79,7 @@ const getHandlerSource = (ctx) => `
79
79
  const staticRoutes = staticRoutesRaw.map((route) => {
80
80
  return {
81
81
  ...route,
82
- namedRegex: new RegExp(
83
- "^" + escapeStringRegexp(route.page) + "$"
84
- )
82
+ namedRegex: new RegExp(`^${escapeStringRegexp(route.page)}$`)
85
83
  };
86
84
  });
87
85
  let appPathRoutesManifest = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-community/adapter-vercel",
3
- "version": "0.0.1-beta.23",
3
+ "version": "0.0.1-beta.24",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "@types/bytes": "3.1.1",
14
14
  "@types/convert-source-map": "1.5.2",
15
15
  "@types/fs-extra": "8.0.0",
16
- "@types/node": "14.18.33",
16
+ "@types/node": "20.6.5",
17
17
  "@types/picomatch": "2.3.3",
18
18
  "@types/webpack-sources": "3.2.0",
19
19
  "@vercel/build-utils": "13.6.2",
@@ -28,9 +28,6 @@
28
28
  "source-map": "0.7.4",
29
29
  "webpack-sources": "3.2.3"
30
30
  },
31
- "peerDependencies": {
32
- "next": ">= 16.1.1-canary.18"
33
- },
34
31
  "engines": {
35
32
  "node": ">= 20.6.0"
36
33
  },