@hono/vite-build 1.9.2 → 1.9.3
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 +7 -0
- package/dist/adapter/bun/index.d.ts +2 -1
- package/dist/adapter/bun/index.js +30 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @hono/vite-build
|
|
2
2
|
|
|
3
|
+
## 1.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#337](https://github.com/honojs/vite-plugins/pull/337) [`a759e7533a915215154d4a211893d309e80199b4`](https://github.com/honojs/vite-plugins/commit/a759e7533a915215154d4a211893d309e80199b4) Thanks [@meck93](https://github.com/meck93)! - Fix Bun adapter build output to preserve an entry's `websocket` handler in the generated default export.
|
|
8
|
+
This prevents Bun runtime WebSocket upgrade failures when apps export `{ fetch, websocket }`.
|
|
9
|
+
|
|
3
10
|
## 1.9.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ import '../../entry/index.js';
|
|
|
5
5
|
type BunBuildOptions = {
|
|
6
6
|
staticRoot?: string | undefined;
|
|
7
7
|
} & BuildOptions;
|
|
8
|
+
declare const defaultOptions: BunBuildOptions;
|
|
8
9
|
declare const bunBuildPlugin: (pluginOptions?: BunBuildOptions) => Plugin;
|
|
9
10
|
|
|
10
|
-
export { BunBuildOptions, bunBuildPlugin as default };
|
|
11
|
+
export { BunBuildOptions, bunBuildPlugin as default, defaultOptions };
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
import buildPlugin from "../../base.js";
|
|
1
|
+
import buildPlugin, { defaultOptions as baseDefaultOptions } from "../../base.js";
|
|
2
2
|
import { serveStaticHook } from "../../entry/serve-static.js";
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
...baseDefaultOptions,
|
|
5
|
+
entryContentAfterHooks: [
|
|
6
|
+
() => `
|
|
7
|
+
let websocket
|
|
8
|
+
for (const [, app] of Object.entries(modules)) {
|
|
9
|
+
if (
|
|
10
|
+
app &&
|
|
11
|
+
typeof app === 'object' &&
|
|
12
|
+
'websocket' in app &&
|
|
13
|
+
app.websocket !== undefined
|
|
14
|
+
) {
|
|
15
|
+
if (websocket !== undefined) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
\`Handler "websocket" is defined in multiple entry files. Please ensure each handler is defined only once.\`
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
websocket = app.websocket
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`
|
|
24
|
+
],
|
|
25
|
+
entryContentDefaultExportHook: (appName) => `export default websocket !== undefined ? { fetch: ${appName}.fetch.bind(${appName}), websocket } : ${appName}`
|
|
26
|
+
};
|
|
3
27
|
const bunBuildPlugin = (pluginOptions) => {
|
|
4
28
|
return {
|
|
5
29
|
...buildPlugin({
|
|
@@ -16,12 +40,15 @@ const bunBuildPlugin = (pluginOptions) => {
|
|
|
16
40
|
}
|
|
17
41
|
]
|
|
18
42
|
},
|
|
19
|
-
...pluginOptions
|
|
43
|
+
...pluginOptions,
|
|
44
|
+
entryContentAfterHooks: pluginOptions?.entryContentAfterHooks ?? defaultOptions.entryContentAfterHooks,
|
|
45
|
+
entryContentDefaultExportHook: pluginOptions?.entryContentDefaultExportHook ?? defaultOptions.entryContentDefaultExportHook
|
|
20
46
|
}),
|
|
21
47
|
name: "@hono/vite-build/bun"
|
|
22
48
|
};
|
|
23
49
|
};
|
|
24
50
|
var bun_default = bunBuildPlugin;
|
|
25
51
|
export {
|
|
26
|
-
bun_default as default
|
|
52
|
+
bun_default as default,
|
|
53
|
+
defaultOptions
|
|
27
54
|
};
|