@vercel/hono 0.0.6 → 0.0.9
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 +25 -44
- package/package.json +4 -4
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,55 +30,45 @@ 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
|
-
entrypoint
|
|
39
|
-
useWebApi: true,
|
|
40
|
-
shim
|
|
39
|
+
entrypoint
|
|
41
40
|
});
|
|
42
41
|
};
|
|
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
42
|
var findEntrypoint = (files) => {
|
|
60
43
|
const validEntrypoints = [
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"index.
|
|
64
|
-
"index.
|
|
65
|
-
"index.
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
44
|
+
["index.cjs"],
|
|
45
|
+
["index.js"],
|
|
46
|
+
["index.mjs"],
|
|
47
|
+
["index.mts"],
|
|
48
|
+
["index.ts"],
|
|
49
|
+
["server.cjs"],
|
|
50
|
+
["server.js"],
|
|
51
|
+
["server.mjs"],
|
|
52
|
+
["server.mts"],
|
|
53
|
+
["server.ts"],
|
|
54
|
+
["src", "index.cjs"],
|
|
55
|
+
["src", "index.js"],
|
|
56
|
+
["src", "index.mjs"],
|
|
57
|
+
["src", "index.mts"],
|
|
58
|
+
["src", "index.ts"]
|
|
71
59
|
];
|
|
72
|
-
const entrypoint = validEntrypoints.find((
|
|
60
|
+
const entrypoint = validEntrypoints.find((entrypointParts) => {
|
|
61
|
+
const path = entrypointParts.join(import_path.sep);
|
|
62
|
+
return files[path] !== void 0;
|
|
63
|
+
});
|
|
73
64
|
if (!entrypoint) {
|
|
74
65
|
throw new Error("No valid entrypoint found");
|
|
75
66
|
}
|
|
76
|
-
return entrypoint;
|
|
67
|
+
return entrypoint.join(import_path.sep);
|
|
77
68
|
};
|
|
78
69
|
|
|
79
70
|
// src/index.ts
|
|
80
71
|
var import_node2 = require("@vercel/node");
|
|
81
|
-
var import_promises = require("fs/promises");
|
|
82
|
-
var import_path = require("path");
|
|
83
72
|
var version = 3;
|
|
84
73
|
var shouldServe = async (opts) => {
|
|
85
74
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
@@ -90,24 +79,16 @@ var shouldServe = async (opts) => {
|
|
|
90
79
|
};
|
|
91
80
|
var startDevServer = async (opts) => {
|
|
92
81
|
const entrypoint = findEntrypoint(opts.files);
|
|
93
|
-
|
|
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);
|
|
82
|
+
process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1";
|
|
101
83
|
return (0, import_node2.startDevServer)({
|
|
102
84
|
...opts,
|
|
103
|
-
entrypoint
|
|
85
|
+
entrypoint
|
|
104
86
|
});
|
|
105
87
|
};
|
|
106
88
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
89
|
0 && (module.exports = {
|
|
108
90
|
build,
|
|
109
91
|
findEntrypoint,
|
|
110
|
-
shim,
|
|
111
92
|
shouldServe,
|
|
112
93
|
startDevServer,
|
|
113
94
|
version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/hono",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@vercel/static-config": "3.1.1",
|
|
18
|
-
"@vercel/node": "5.3.
|
|
18
|
+
"@vercel/node": "5.3.11",
|
|
19
19
|
"ts-morph": "12.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "node ../../utils/build-builder.mjs",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"vitest-run": "vitest -c ../../vitest.config.mts",
|
|
34
|
+
"vitest-unit": "glob --absolute 'test/unit/**/*.test.ts' 'test/unit/**/*.test.mts'",
|
|
35
35
|
"type-check": "tsc --noEmit"
|
|
36
36
|
}
|
|
37
37
|
}
|