@hono/vite-build 1.6.2 → 1.8.0
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/CHANGELOG.md +153 -0
- package/README.md +2 -0
- package/dist/adapter/node/index.d.ts +8 -0
- package/dist/adapter/node/index.js +16 -1
- package/dist/base.js +5 -2
- package/dist/entry/index.d.ts +7 -1
- package/dist/entry/index.js +5 -1
- package/package.json +4 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @hono/vite-build
|
|
2
|
+
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#315](https://github.com/honojs/vite-plugins/pull/315) [`d9ecb01ac8220d85c539081b139e4117b53ba711`](https://github.com/honojs/vite-plugins/commit/d9ecb01ac8220d85c539081b139e4117b53ba711) Thanks [@chadxz](https://github.com/chadxz)! - Added `shutdownTimeoutMs` option to the Node adapter for graceful shutdown on SIGINT/SIGTERM signals. Set to a timeout in milliseconds to enable graceful shutdown, or 0 to wait indefinitely for connections to close.
|
|
8
|
+
|
|
9
|
+
## 1.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#279](https://github.com/honojs/vite-plugins/pull/279) [`b45925cf08f82d607f850191589ff154d0c1ea5f`](https://github.com/honojs/vite-plugins/commit/b45925cf08f82d607f850191589ff154d0c1ea5f) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: add `preset` option
|
|
14
|
+
|
|
15
|
+
## 1.6.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#266](https://github.com/honojs/vite-plugins/pull/266) [`7e51cc7f29d0d64dc4bd9c27e0f6c5491ccba5c8`](https://github.com/honojs/vite-plugins/commit/7e51cc7f29d0d64dc4bd9c27e0f6c5491ccba5c8) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: fix the option types of Cloudflare Workers adapter
|
|
20
|
+
|
|
21
|
+
## 1.6.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#261](https://github.com/honojs/vite-plugins/pull/261) [`c116701a2423eb9882de6559223304b66305a281`](https://github.com/honojs/vite-plugins/commit/c116701a2423eb9882de6559223304b66305a281) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: correct `CloudflareWorkersBuildOptions` type
|
|
26
|
+
|
|
27
|
+
## 1.6.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [#254](https://github.com/honojs/vite-plugins/pull/254) [`ee00f8b93a480ab332245c6d661b8001f24028e2`](https://github.com/honojs/vite-plugins/commit/ee00f8b93a480ab332245c6d661b8001f24028e2) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: export `defaultOptions` from Cloudflare Workers adpater
|
|
32
|
+
|
|
33
|
+
## 1.5.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- [#247](https://github.com/honojs/vite-plugins/pull/247) [`e7f58050840cf2f6a1ec446e3e4e89b0b0a85014`](https://github.com/honojs/vite-plugins/commit/e7f58050840cf2f6a1ec446e3e4e89b0b0a85014) Thanks [@toga4](https://github.com/toga4)! - feat(build): support non-fetch handlers for Cloudflare Workers
|
|
38
|
+
|
|
39
|
+
## 1.4.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- [#241](https://github.com/honojs/vite-plugins/pull/241) [`314c66da2b656d4705c4d0636cd1623b643dbd61`](https://github.com/honojs/vite-plugins/commit/314c66da2b656d4705c4d0636cd1623b643dbd61) Thanks [@justblender](https://github.com/justblender)! - Added a new Vercel build adapter.
|
|
44
|
+
|
|
45
|
+
This adapter can be imported from `@hono/vite-build/vercel` and will compile
|
|
46
|
+
your Hono app to comply with the specification requirements of the Vercel Build Output API.
|
|
47
|
+
|
|
48
|
+
Please note that this adapter produces output suitable only for Vercel Serverless Functions.
|
|
49
|
+
It does not support the Edge Runtime, which appears to be gradually phased out in favor of Vercel's Fluid compute architecture.
|
|
50
|
+
|
|
51
|
+
The default export will have the `@hono/node-server/vercel` adapter applied to it.
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- [#244](https://github.com/honojs/vite-plugins/pull/244) [`2d8d6d202a106de6049febc524c29ec24f6911b9`](https://github.com/honojs/vite-plugins/commit/2d8d6d202a106de6049febc524c29ec24f6911b9) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: enable `staticPaths` option
|
|
56
|
+
|
|
57
|
+
## 1.3.1
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- [#242](https://github.com/honojs/vite-plugins/pull/242) [`88ca94493ebb39cafe0d42bb741cce870ef58c68`](https://github.com/honojs/vite-plugins/commit/88ca94493ebb39cafe0d42bb741cce870ef58c68) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: support `fetch` export
|
|
62
|
+
|
|
63
|
+
## 1.3.0
|
|
64
|
+
|
|
65
|
+
### Minor Changes
|
|
66
|
+
|
|
67
|
+
- [#218](https://github.com/honojs/vite-plugins/pull/218) [`65e2f768a26d0665aaa05f60abf36bb66a6b6fa9`](https://github.com/honojs/vite-plugins/commit/65e2f768a26d0665aaa05f60abf36bb66a6b6fa9) Thanks [@chadxz](https://github.com/chadxz)! - Added a new Netlify Functions build adapter.
|
|
68
|
+
|
|
69
|
+
This adapter can be imported from `@hono/vite-build/netlify-functions` and will
|
|
70
|
+
compile your Hono app to comply with the requirements of the Netlify Functions
|
|
71
|
+
runtime.
|
|
72
|
+
|
|
73
|
+
- The default export will have the `hono/netlify` adapter applied to it.
|
|
74
|
+
- A `config` object will be exported, setting the function path to `'/*'` and
|
|
75
|
+
`preferStatic` to `true`.
|
|
76
|
+
|
|
77
|
+
Please note, this is for the Netlify Functions runtime, not the Netlify Edge
|
|
78
|
+
Functions runtime.
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// vite.config.ts
|
|
84
|
+
import { defineConfig } from 'vite'
|
|
85
|
+
import devServer from '@hono/vite-dev-server'
|
|
86
|
+
import build from '@hono/vite-build/netlify-functions'
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
plugins: [
|
|
90
|
+
devServer({
|
|
91
|
+
entry: './src/index.ts',
|
|
92
|
+
}),
|
|
93
|
+
build({
|
|
94
|
+
entry: './src/index.ts',
|
|
95
|
+
output: 'functions/server/index.js',
|
|
96
|
+
}),
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
If you also have a `public/publish` directory for your assets that should be
|
|
102
|
+
published to the corresponding Netlify site, then after running a build, you
|
|
103
|
+
would end up with a directory structure like:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
dist/
|
|
107
|
+
functions/
|
|
108
|
+
server/
|
|
109
|
+
index.js
|
|
110
|
+
publish/
|
|
111
|
+
robots.txt
|
|
112
|
+
....
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
then you can use a netlify.toml that looks like:
|
|
116
|
+
|
|
117
|
+
```toml
|
|
118
|
+
# https://ntl.fyi/file-based-build-config
|
|
119
|
+
[build]
|
|
120
|
+
command = "vite build"
|
|
121
|
+
functions = "dist/functions"
|
|
122
|
+
publish = "dist/publish"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 1.2.1
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- [#204](https://github.com/honojs/vite-plugins/pull/204) [`adcdd9ad7a3c7ef6a828dfa1210ba5d08eadc576`](https://github.com/honojs/vite-plugins/commit/adcdd9ad7a3c7ef6a828dfa1210ba5d08eadc576) Thanks [@jonz94](https://github.com/jonz94)! - fix(build): remove `console.log`
|
|
130
|
+
|
|
131
|
+
## 1.2.0
|
|
132
|
+
|
|
133
|
+
### Minor Changes
|
|
134
|
+
|
|
135
|
+
- [#198](https://github.com/honojs/vite-plugins/pull/198) [`f08c6586018c0da828158ec252be4d889f8c32e8`](https://github.com/honojs/vite-plugins/commit/f08c6586018c0da828158ec252be4d889f8c32e8) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: Node.js adapter supports `port` option
|
|
136
|
+
|
|
137
|
+
## 1.1.1
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- [#196](https://github.com/honojs/vite-plugins/pull/196) [`ead8c3255f2d7fb68084b8d30c3fbe9fcaabb3ec`](https://github.com/honojs/vite-plugins/commit/ead8c3255f2d7fb68084b8d30c3fbe9fcaabb3ec) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: support latest `hono`
|
|
142
|
+
|
|
143
|
+
## 1.1.0
|
|
144
|
+
|
|
145
|
+
### Minor Changes
|
|
146
|
+
|
|
147
|
+
- [#181](https://github.com/honojs/vite-plugins/pull/181) [`fc15f718c0172f84748f8717f53abba40470baed`](https://github.com/honojs/vite-plugins/commit/fc15f718c0172f84748f8717f53abba40470baed) Thanks [@nakasyou](https://github.com/nakasyou)! - Added Deno adapter
|
|
148
|
+
|
|
149
|
+
## 1.0.0
|
|
150
|
+
|
|
151
|
+
### Major Changes
|
|
152
|
+
|
|
153
|
+
- [#177](https://github.com/honojs/vite-plugins/pull/177) [`1ceb95757f1151e9f08cebd992447fb67b470957`](https://github.com/honojs/vite-plugins/commit/1ceb95757f1151e9f08cebd992447fb67b470957) Thanks [@yusukebe](https://github.com/yusukebe)! - Initial release
|
package/README.md
CHANGED
|
@@ -100,6 +100,7 @@ type BuildOptions = {
|
|
|
100
100
|
external?: string[]
|
|
101
101
|
minify?: boolean
|
|
102
102
|
emptyOutDir?: boolean
|
|
103
|
+
preset?: 'hono' | 'hono/tiny' | 'hono/quick'
|
|
103
104
|
}
|
|
104
105
|
```
|
|
105
106
|
|
|
@@ -114,6 +115,7 @@ export const defaultOptions = {
|
|
|
114
115
|
minify: true,
|
|
115
116
|
emptyOutDir: false,
|
|
116
117
|
staticPaths: [],
|
|
118
|
+
preset: 'hono',
|
|
117
119
|
}
|
|
118
120
|
```
|
|
119
121
|
|
|
@@ -5,6 +5,14 @@ import '../../entry/index.js';
|
|
|
5
5
|
type NodeBuildOptions = {
|
|
6
6
|
staticRoot?: string | undefined;
|
|
7
7
|
port?: number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Enable graceful shutdown on SIGINT and SIGTERM signals.
|
|
10
|
+
* Set to a number to specify the timeout in milliseconds before forcing shutdown.
|
|
11
|
+
* Set to 0 to wait indefinitely for connections to close.
|
|
12
|
+
* Leave undefined to disable graceful shutdown.
|
|
13
|
+
* @default undefined
|
|
14
|
+
*/
|
|
15
|
+
shutdownTimeoutMs?: number | undefined;
|
|
8
16
|
} & BuildOptions;
|
|
9
17
|
declare const nodeBuildPlugin: (pluginOptions?: NodeBuildOptions) => Plugin;
|
|
10
18
|
|
|
@@ -2,6 +2,7 @@ import buildPlugin from "../../base.js";
|
|
|
2
2
|
import { serveStaticHook } from "../../entry/serve-static.js";
|
|
3
3
|
const nodeBuildPlugin = (pluginOptions) => {
|
|
4
4
|
const port = pluginOptions?.port ?? 3e3;
|
|
5
|
+
const shutdownTimeoutMs = pluginOptions?.shutdownTimeoutMs;
|
|
5
6
|
return {
|
|
6
7
|
...buildPlugin({
|
|
7
8
|
...{
|
|
@@ -18,7 +19,21 @@ const nodeBuildPlugin = (pluginOptions) => {
|
|
|
18
19
|
entryContentAfterHooks: [
|
|
19
20
|
async (appName) => {
|
|
20
21
|
let code = "import { serve } from '@hono/node-server'\n";
|
|
21
|
-
|
|
22
|
+
if (shutdownTimeoutMs !== void 0) {
|
|
23
|
+
code += `const server = serve({ fetch: ${appName}.fetch, port: ${port.toString()} })
|
|
24
|
+
`;
|
|
25
|
+
code += "const gracefulShutdown = () => {\n";
|
|
26
|
+
code += " server.close(() => process.exit(0))\n";
|
|
27
|
+
if (shutdownTimeoutMs > 0) {
|
|
28
|
+
code += ` setTimeout(() => process.exit(1), ${shutdownTimeoutMs}).unref()
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
code += "}\n";
|
|
32
|
+
code += "process.on('SIGINT', gracefulShutdown)\n";
|
|
33
|
+
code += "process.on('SIGTERM', gracefulShutdown)";
|
|
34
|
+
} else {
|
|
35
|
+
code += `serve({ fetch: ${appName}.fetch, port: ${port.toString()} })`;
|
|
36
|
+
}
|
|
22
37
|
return code;
|
|
23
38
|
}
|
|
24
39
|
]
|
package/dist/base.js
CHANGED
|
@@ -15,13 +15,15 @@ const defaultOptions = {
|
|
|
15
15
|
}
|
|
16
16
|
return false;
|
|
17
17
|
},
|
|
18
|
-
staticPaths: []
|
|
18
|
+
staticPaths: [],
|
|
19
|
+
preset: "hono"
|
|
19
20
|
};
|
|
20
21
|
const buildPlugin = (options) => {
|
|
21
22
|
const virtualEntryId = "virtual:build-entry-module";
|
|
22
23
|
const resolvedVirtualEntryId = "\0" + virtualEntryId;
|
|
23
24
|
let config;
|
|
24
25
|
const output = options.output ?? defaultOptions.output;
|
|
26
|
+
const preset = options.preset ?? defaultOptions.preset;
|
|
25
27
|
return {
|
|
26
28
|
name: "@hono/vite-build",
|
|
27
29
|
configResolved: async (resolvedConfig) => {
|
|
@@ -65,7 +67,8 @@ const buildPlugin = (options) => {
|
|
|
65
67
|
entryContentBeforeHooks: options.entryContentBeforeHooks,
|
|
66
68
|
entryContentAfterHooks: options.entryContentAfterHooks,
|
|
67
69
|
entryContentDefaultExportHook: options.entryContentDefaultExportHook,
|
|
68
|
-
staticPaths
|
|
70
|
+
staticPaths,
|
|
71
|
+
preset
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
},
|
package/dist/entry/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ type EntryContentHookOptions = {
|
|
|
2
2
|
staticPaths: string[];
|
|
3
3
|
};
|
|
4
4
|
type EntryContentHook = (appName: string, options?: EntryContentHookOptions) => string | Promise<string>;
|
|
5
|
+
declare const presets: readonly ["hono", "hono/tiny", "hono/quick"];
|
|
6
|
+
type Preset = (typeof presets)[number];
|
|
5
7
|
type GetEntryContentOptions = {
|
|
6
8
|
entry: string[];
|
|
7
9
|
entryContentBeforeHooks?: EntryContentHook[];
|
|
@@ -14,7 +16,11 @@ type GetEntryContentOptions = {
|
|
|
14
16
|
*/
|
|
15
17
|
entryContentDefaultExportHook?: EntryContentHook;
|
|
16
18
|
staticPaths?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* @default `hono`
|
|
21
|
+
*/
|
|
22
|
+
preset?: Preset;
|
|
17
23
|
};
|
|
18
24
|
declare const getEntryContent: (options: GetEntryContentOptions) => Promise<string>;
|
|
19
25
|
|
|
20
|
-
export { EntryContentHook, EntryContentHookOptions, GetEntryContentOptions, getEntryContent };
|
|
26
|
+
export { EntryContentHook, EntryContentHookOptions, GetEntryContentOptions, Preset, getEntryContent };
|
package/dist/entry/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalize } from "node:path";
|
|
2
|
+
const presets = ["hono", "hono/tiny", "hono/quick"];
|
|
2
3
|
const normalizePaths = (paths) => {
|
|
3
4
|
return paths.map((p) => {
|
|
4
5
|
let normalizedPath = normalize(p).replace(/\\/g, "/");
|
|
@@ -9,6 +10,9 @@ const normalizePaths = (paths) => {
|
|
|
9
10
|
});
|
|
10
11
|
};
|
|
11
12
|
const getEntryContent = async (options) => {
|
|
13
|
+
const preset = presets.includes(options.preset ?? "hono") ? options.preset ?? "hono" : (console.warn(
|
|
14
|
+
`Invalid preset: ${options.preset}. Must be one of: ${presets.join(", ")}. Using 'hono' as default.`
|
|
15
|
+
), "hono");
|
|
12
16
|
const staticPaths = options.staticPaths ?? [""];
|
|
13
17
|
const globStr = normalizePaths(options.entry).map((e) => `'${e}'`).join(",");
|
|
14
18
|
const hooksToString = async (appName, hooks) => {
|
|
@@ -49,7 +53,7 @@ const getEntryContent = async (options) => {
|
|
|
49
53
|
throw new Error("Can't import modules from [${globStr}]")
|
|
50
54
|
}`;
|
|
51
55
|
const defaultExportHook = options.entryContentDefaultExportHook ?? (() => "export default mainApp");
|
|
52
|
-
return `import { Hono } from '
|
|
56
|
+
return `import { Hono } from '${preset}'
|
|
53
57
|
const mainApp = new Hono()
|
|
54
58
|
|
|
55
59
|
${await hooksToString("mainApp", options.entryContentBeforeHooks)}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/vite-build",
|
|
3
3
|
"description": "Vite plugin to build your Hono app",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -89,6 +89,8 @@
|
|
|
89
89
|
},
|
|
90
90
|
"homepage": "https://github.com/honojs/vite-plugins",
|
|
91
91
|
"devDependencies": {
|
|
92
|
+
"@hono/node-server": "^1.19.6",
|
|
93
|
+
"@types/node": "^24.10.0",
|
|
92
94
|
"glob": "^10.3.10",
|
|
93
95
|
"hono": "^4.6.12",
|
|
94
96
|
"publint": "^0.1.12",
|
|
@@ -103,4 +105,4 @@
|
|
|
103
105
|
"engines": {
|
|
104
106
|
"node": ">=18.14.1"
|
|
105
107
|
}
|
|
106
|
-
}
|
|
108
|
+
}
|