@hono/vite-build 1.1.0 → 1.2.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/README.md +6 -0
- package/dist/adapter/node/index.d.ts +1 -0
- package/dist/adapter/node/index.js +2 -1
- package/dist/entry/index.js +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -42,6 +42,8 @@ export default defineConfig({
|
|
|
42
42
|
build({
|
|
43
43
|
// Defaults are `src/index.ts`,`./src/index.tsx`,`./app/server.ts`
|
|
44
44
|
entry: './src/index.tsx',
|
|
45
|
+
// port option is only for Node.js adapter. Default is 3000
|
|
46
|
+
port: 3001,
|
|
45
47
|
}),
|
|
46
48
|
],
|
|
47
49
|
})
|
|
@@ -212,6 +214,10 @@ app.get('/', (c) => {
|
|
|
212
214
|
})
|
|
213
215
|
```
|
|
214
216
|
|
|
217
|
+
## Example
|
|
218
|
+
|
|
219
|
+
You can see the example project here - [hono-vite-jsx](https://github.com/honojs/examples/tree/main/hono-vite-jsx)
|
|
220
|
+
|
|
215
221
|
## Authors
|
|
216
222
|
|
|
217
223
|
- Yusuke Wada <https://github.com/yusukebe>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import buildPlugin from "../../base.js";
|
|
2
2
|
import { serveStaticHook } from "../../entry/serve-static.js";
|
|
3
3
|
const nodeBuildPlugin = (pluginOptions) => {
|
|
4
|
+
const port = pluginOptions?.port ?? 3e3;
|
|
4
5
|
return {
|
|
5
6
|
...buildPlugin({
|
|
6
7
|
...{
|
|
@@ -17,7 +18,7 @@ const nodeBuildPlugin = (pluginOptions) => {
|
|
|
17
18
|
entryContentAfterHooks: [
|
|
18
19
|
async (appName) => {
|
|
19
20
|
let code = "import { serve } from '@hono/node-server'\n";
|
|
20
|
-
code += `serve(${appName})`;
|
|
21
|
+
code += `serve({ fetch: ${appName}.fetch, port: ${port.toString()} })`;
|
|
21
22
|
return code;
|
|
22
23
|
}
|
|
23
24
|
]
|
package/dist/entry/index.js
CHANGED
|
@@ -29,7 +29,14 @@ const getEntryContent = async (options) => {
|
|
|
29
29
|
for (const [, app] of Object.entries(modules)) {
|
|
30
30
|
if (app) {
|
|
31
31
|
mainApp.route('/', app)
|
|
32
|
-
mainApp.notFound(
|
|
32
|
+
mainApp.notFound((c) => {
|
|
33
|
+
let executionCtx
|
|
34
|
+
try {
|
|
35
|
+
executionCtx = c.executionCtx
|
|
36
|
+
} catch {}
|
|
37
|
+
return app.fetch(c.req.raw, c.env, executionCtx)
|
|
38
|
+
})
|
|
39
|
+
console.log(app.notFoundHandler)
|
|
33
40
|
added = true
|
|
34
41
|
}
|
|
35
42
|
}
|
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.2.0",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"homepage": "https://github.com/honojs/vite-plugins",
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"glob": "^10.3.10",
|
|
76
|
-
"hono": "^4.6.
|
|
76
|
+
"hono": "^4.6.12",
|
|
77
77
|
"publint": "^0.1.12",
|
|
78
78
|
"rimraf": "^5.0.1",
|
|
79
79
|
"tsup": "^7.2.0",
|