@vercel/hono 0.0.8 → 0.0.13

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -44
  2. package/package.json +8 -5
package/dist/index.js CHANGED
@@ -22,7 +22,6 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  build: () => build,
24
24
  findEntrypoint: () => findEntrypoint,
25
- shim: () => shim,
26
25
  shouldServe: () => shouldServe,
27
26
  startDevServer: () => startDevServer,
28
27
  version: () => version
@@ -31,83 +30,66 @@ module.exports = __toCommonJS(src_exports);
31
30
 
32
31
  // src/build.ts
33
32
  var import_node = require("@vercel/node");
33
+ var import_path = require("path");
34
34
  var build = async (args) => {
35
35
  const entrypoint = findEntrypoint(args.files);
36
+ process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1";
36
37
  return (0, import_node.build)({
37
38
  ...args,
38
39
  entrypoint,
39
- useWebApi: true,
40
- shim
40
+ considerBuildCommand: true
41
41
  });
42
42
  };
43
- var shim = (handler, relativePathToHandler = ".") => `
44
- // @ts-ignore
45
- import app from "${relativePathToHandler}/${handler}";
46
-
47
- // @ts-ignore
48
- const handle = async (request) => {
49
- return app.fetch(request);
50
- };
51
-
52
- export const GET = handle;
53
- export const POST = handle;
54
- export const PUT = handle;
55
- export const DELETE = handle;
56
- export const PATCH = handle;
57
- export const OPTIONS = handle;
58
- export const HEAD = handle;`;
59
43
  var findEntrypoint = (files) => {
60
44
  const validEntrypoints = [
61
- "server.ts",
62
- "server.js",
63
- "index.ts",
64
- "index.js",
65
- "index.mjs",
66
- "index.cjs",
67
- "src/index.ts",
68
- "src/index.js",
69
- "src/index.mjs",
70
- "src/index.cjs"
45
+ ["index.cjs"],
46
+ ["index.js"],
47
+ ["index.mjs"],
48
+ ["index.mts"],
49
+ ["index.ts"],
50
+ ["server.cjs"],
51
+ ["server.js"],
52
+ ["server.mjs"],
53
+ ["server.mts"],
54
+ ["server.ts"],
55
+ ["src", "index.cjs"],
56
+ ["src", "index.js"],
57
+ ["src", "index.mjs"],
58
+ ["src", "index.mts"],
59
+ ["src", "index.ts"]
71
60
  ];
72
- const entrypoint = validEntrypoints.find((path) => files[path] !== void 0);
61
+ const entrypoint = validEntrypoints.find((entrypointParts) => {
62
+ const path = entrypointParts.join(import_path.sep);
63
+ return files[path] !== void 0;
64
+ });
73
65
  if (!entrypoint) {
74
66
  throw new Error("No valid entrypoint found");
75
67
  }
76
- return entrypoint;
68
+ return entrypoint.join(import_path.sep);
77
69
  };
78
70
 
79
71
  // src/index.ts
80
72
  var import_node2 = require("@vercel/node");
81
- var import_promises = require("fs/promises");
82
- var import_path = require("path");
83
73
  var version = 3;
84
74
  var shouldServe = async (opts) => {
85
75
  const requestPath = opts.requestPath.replace(/\/$/, "");
86
- if (requestPath.startsWith("api")) {
76
+ if (requestPath.startsWith("api") && opts.hasMatched) {
87
77
  return false;
88
78
  }
89
79
  return true;
90
80
  };
91
81
  var startDevServer = async (opts) => {
92
82
  const entrypoint = findEntrypoint(opts.files);
93
- const entrypointExtension = entrypoint.split(".").pop();
94
- const shimString = shim(entrypoint, "../..");
95
- const shimEntrypoint = `.vercel/dev/shim.${entrypointExtension}`;
96
- const shimEntrypointPath = (0, import_path.join)(opts.workPath, shimEntrypoint);
97
- const shimEntrypointDir = (0, import_path.dirname)(shimEntrypointPath);
98
- await (0, import_promises.rm)(shimEntrypointDir, { force: true, recursive: true });
99
- await (0, import_promises.mkdir)(shimEntrypointDir, { recursive: true });
100
- await (0, import_promises.writeFile)(shimEntrypointPath, shimString);
83
+ process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1";
101
84
  return (0, import_node2.startDevServer)({
102
85
  ...opts,
103
- entrypoint: shimEntrypoint
86
+ entrypoint
104
87
  });
105
88
  };
106
89
  // Annotate the CommonJS export names for ESM import in node:
107
90
  0 && (module.exports = {
108
91
  build,
109
92
  findEntrypoint,
110
- shim,
111
93
  shouldServe,
112
94
  startDevServer,
113
95
  version
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@vercel/hono",
3
- "version": "0.0.8",
3
+ "version": "0.0.13",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "https://github.com/vercel/vercel.git",
@@ -15,13 +18,13 @@
15
18
  ],
16
19
  "dependencies": {
17
20
  "@vercel/static-config": "3.1.1",
18
- "@vercel/node": "5.3.10",
21
+ "@vercel/node": "5.3.12",
19
22
  "ts-morph": "12.0.0"
20
23
  },
21
24
  "devDependencies": {
22
25
  "@types/jest": "27.5.1",
23
26
  "@types/node": "14.18.33",
24
- "@vercel/build-utils": "11.0.0",
27
+ "@vercel/build-utils": "11.0.1",
25
28
  "execa": "3.2.0",
26
29
  "fs-extra": "11.1.0",
27
30
  "jest-junit": "16.0.0",
@@ -30,8 +33,8 @@
30
33
  },
31
34
  "scripts": {
32
35
  "build": "node ../../utils/build-builder.mjs",
33
- "test-e2e": "pnpm test test/test.js",
34
- "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand",
36
+ "vitest-run": "vitest -c ../../vitest.config.mts",
37
+ "vitest-unit": "glob --absolute 'test/unit/**/*.test.ts' 'test/unit/**/*.test.mts'",
35
38
  "type-check": "tsc --noEmit"
36
39
  }
37
40
  }