@hono/vite-build 1.7.0 → 1.9.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 ADDED
@@ -0,0 +1,159 @@
1
+ # @hono/vite-build
2
+
3
+ ## 1.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#328](https://github.com/honojs/vite-plugins/pull/328) [`3e9010da1687c46e610a5ea9ec7a80c9be57684a`](https://github.com/honojs/vite-plugins/commit/3e9010da1687c46e610a5ea9ec7a80c9be57684a) Thanks [@yusukebe](https://github.com/yusukebe)! - feat: add `ssrTarget` option
8
+
9
+ ## 1.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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.
14
+
15
+ ## 1.7.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#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
20
+
21
+ ## 1.6.2
22
+
23
+ ### Patch Changes
24
+
25
+ - [#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
26
+
27
+ ## 1.6.1
28
+
29
+ ### Patch Changes
30
+
31
+ - [#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
32
+
33
+ ## 1.6.0
34
+
35
+ ### Minor Changes
36
+
37
+ - [#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
38
+
39
+ ## 1.5.0
40
+
41
+ ### Minor Changes
42
+
43
+ - [#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
44
+
45
+ ## 1.4.0
46
+
47
+ ### Minor Changes
48
+
49
+ - [#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.
50
+
51
+ This adapter can be imported from `@hono/vite-build/vercel` and will compile
52
+ your Hono app to comply with the specification requirements of the Vercel Build Output API.
53
+
54
+ Please note that this adapter produces output suitable only for Vercel Serverless Functions.
55
+ It does not support the Edge Runtime, which appears to be gradually phased out in favor of Vercel's Fluid compute architecture.
56
+
57
+ The default export will have the `@hono/node-server/vercel` adapter applied to it.
58
+
59
+ ### Patch Changes
60
+
61
+ - [#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
62
+
63
+ ## 1.3.1
64
+
65
+ ### Patch Changes
66
+
67
+ - [#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
68
+
69
+ ## 1.3.0
70
+
71
+ ### Minor Changes
72
+
73
+ - [#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.
74
+
75
+ This adapter can be imported from `@hono/vite-build/netlify-functions` and will
76
+ compile your Hono app to comply with the requirements of the Netlify Functions
77
+ runtime.
78
+
79
+ - The default export will have the `hono/netlify` adapter applied to it.
80
+ - A `config` object will be exported, setting the function path to `'/*'` and
81
+ `preferStatic` to `true`.
82
+
83
+ Please note, this is for the Netlify Functions runtime, not the Netlify Edge
84
+ Functions runtime.
85
+
86
+ Example:
87
+
88
+ ```ts
89
+ // vite.config.ts
90
+ import { defineConfig } from 'vite'
91
+ import devServer from '@hono/vite-dev-server'
92
+ import build from '@hono/vite-build/netlify-functions'
93
+
94
+ export default defineConfig({
95
+ plugins: [
96
+ devServer({
97
+ entry: './src/index.ts',
98
+ }),
99
+ build({
100
+ entry: './src/index.ts',
101
+ output: 'functions/server/index.js',
102
+ }),
103
+ ],
104
+ })
105
+ ```
106
+
107
+ If you also have a `public/publish` directory for your assets that should be
108
+ published to the corresponding Netlify site, then after running a build, you
109
+ would end up with a directory structure like:
110
+
111
+ ```
112
+ dist/
113
+ functions/
114
+ server/
115
+ index.js
116
+ publish/
117
+ robots.txt
118
+ ....
119
+ ```
120
+
121
+ then you can use a netlify.toml that looks like:
122
+
123
+ ```toml
124
+ # https://ntl.fyi/file-based-build-config
125
+ [build]
126
+ command = "vite build"
127
+ functions = "dist/functions"
128
+ publish = "dist/publish"
129
+ ```
130
+
131
+ ## 1.2.1
132
+
133
+ ### Patch Changes
134
+
135
+ - [#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`
136
+
137
+ ## 1.2.0
138
+
139
+ ### Minor Changes
140
+
141
+ - [#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
142
+
143
+ ## 1.1.1
144
+
145
+ ### Patch Changes
146
+
147
+ - [#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`
148
+
149
+ ## 1.1.0
150
+
151
+ ### Minor Changes
152
+
153
+ - [#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
154
+
155
+ ## 1.0.0
156
+
157
+ ### Major Changes
158
+
159
+ - [#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
@@ -3,6 +3,7 @@ import { serveStaticHook } from "../../entry/serve-static.js";
3
3
  const bunBuildPlugin = (pluginOptions) => {
4
4
  return {
5
5
  ...buildPlugin({
6
+ ssrTarget: "node",
6
7
  ...{
7
8
  entryContentBeforeHooks: [
8
9
  async (appName, options) => {
@@ -2,6 +2,7 @@ import buildPlugin from "../../base.js";
2
2
  function netlifyFunctionsBuildPlugin(pluginOptions) {
3
3
  return {
4
4
  ...buildPlugin({
5
+ ssrTarget: "node",
5
6
  ...{
6
7
  entryContentBeforeHooks: [() => 'import { handle } from "hono/netlify"'],
7
8
  entryContentAfterHooks: [() => 'export const config = { path: "/*", preferStatic: true }'],
@@ -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,8 +2,10 @@ 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({
8
+ ssrTarget: "node",
7
9
  ...{
8
10
  entryContentBeforeHooks: [
9
11
  async (appName, options) => {
@@ -18,7 +20,21 @@ const nodeBuildPlugin = (pluginOptions) => {
18
20
  entryContentAfterHooks: [
19
21
  async (appName) => {
20
22
  let code = "import { serve } from '@hono/node-server'\n";
21
- code += `serve({ fetch: ${appName}.fetch, port: ${port.toString()} })`;
23
+ if (shutdownTimeoutMs !== void 0) {
24
+ code += `const server = serve({ fetch: ${appName}.fetch, port: ${port.toString()} })
25
+ `;
26
+ code += "const gracefulShutdown = () => {\n";
27
+ code += " server.close(() => process.exit(0))\n";
28
+ if (shutdownTimeoutMs > 0) {
29
+ code += ` setTimeout(() => process.exit(1), ${shutdownTimeoutMs}).unref()
30
+ `;
31
+ }
32
+ code += "}\n";
33
+ code += "process.on('SIGINT', gracefulShutdown)\n";
34
+ code += "process.on('SIGTERM', gracefulShutdown)";
35
+ } else {
36
+ code += `serve({ fetch: ${appName}.fetch, port: ${port.toString()} })`;
37
+ }
22
38
  return code;
23
39
  }
24
40
  ]
@@ -23,6 +23,7 @@ const vercelBuildPlugin = (pluginOptions) => {
23
23
  let config;
24
24
  return {
25
25
  ...buildPlugin({
26
+ ssrTarget: "node",
26
27
  output: `functions/${FUNCTION_NAME}.func/${BUNDLE_NAME}`,
27
28
  outputDir: ".vercel/output",
28
29
  ...{
package/dist/base.d.ts CHANGED
@@ -18,6 +18,10 @@ type BuildOptions = {
18
18
  minify?: boolean;
19
19
  emptyOutDir?: boolean;
20
20
  apply?: ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined;
21
+ /**
22
+ * @default 'webworker'
23
+ */
24
+ ssrTarget?: 'node' | 'webworker';
21
25
  } & Omit<GetEntryContentOptions, 'entry'>;
22
26
  declare const defaultOptions: Required<Omit<BuildOptions, 'entryContentAfterHooks' | 'entryContentBeforeHooks' | 'entryContentDefaultExportHook'>>;
23
27
  declare const buildPlugin: (options: BuildOptions) => Plugin;
package/dist/base.js CHANGED
@@ -16,7 +16,8 @@ const defaultOptions = {
16
16
  return false;
17
17
  },
18
18
  staticPaths: [],
19
- preset: "hono"
19
+ preset: "hono",
20
+ ssrTarget: "webworker"
20
21
  };
21
22
  const buildPlugin = (options) => {
22
23
  const virtualEntryId = "virtual:build-entry-module";
@@ -78,7 +79,7 @@ const buildPlugin = (options) => {
78
79
  ssr: {
79
80
  external: options?.external ?? defaultOptions.external,
80
81
  noExternal: true,
81
- target: "webworker"
82
+ target: options?.ssrTarget ?? defaultOptions.ssrTarget
82
83
  },
83
84
  build: {
84
85
  outDir: options?.outputDir ?? defaultOptions.outputDir,
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.7.0",
4
+ "version": "1.9.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
+ }