@hono/vite-build 1.2.1 → 1.3.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
CHANGED
|
@@ -9,6 +9,7 @@ Here are the modules included:
|
|
|
9
9
|
- `@hono/vite-build/cloudflare-workers`
|
|
10
10
|
- `@hono/vite-build/bun`
|
|
11
11
|
- `@hono/vite-build/node`
|
|
12
|
+
- `@hono/vite-build/netlify-functions`
|
|
12
13
|
|
|
13
14
|
## Usage
|
|
14
15
|
|
|
@@ -36,6 +37,7 @@ import build from '@hono/vite-build/bun'
|
|
|
36
37
|
// import build from '@hono/vite-build/cloudflare-pages'
|
|
37
38
|
// import build from '@hono/vite-build/cloudflare-workers'
|
|
38
39
|
// import build from '@hono/vite-build/node'
|
|
40
|
+
// import build from '@hono/vite-build/netlify-functions'
|
|
39
41
|
|
|
40
42
|
export default defineConfig({
|
|
41
43
|
plugins: [
|
|
@@ -51,7 +53,7 @@ export default defineConfig({
|
|
|
51
53
|
|
|
52
54
|
### Build
|
|
53
55
|
|
|
54
|
-
Just run
|
|
56
|
+
Just run `vite build`.
|
|
55
57
|
|
|
56
58
|
```bash
|
|
57
59
|
npm exec vite build
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { BuildOptions } from '../../base.js';
|
|
3
|
+
import '../../entry/index.js';
|
|
4
|
+
|
|
5
|
+
type NetlifyFunctionsBuildOptions = BuildOptions;
|
|
6
|
+
declare function netlifyFunctionsBuildPlugin(pluginOptions?: NetlifyFunctionsBuildOptions): Plugin;
|
|
7
|
+
|
|
8
|
+
export { NetlifyFunctionsBuildOptions, netlifyFunctionsBuildPlugin as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import buildPlugin from "../../base.js";
|
|
2
|
+
function netlifyFunctionsBuildPlugin(pluginOptions) {
|
|
3
|
+
return {
|
|
4
|
+
...buildPlugin({
|
|
5
|
+
...{
|
|
6
|
+
entryContentBeforeHooks: [() => 'import { handle } from "hono/netlify"'],
|
|
7
|
+
entryContentAfterHooks: [() => 'export const config = { path: "/*", preferStatic: true }'],
|
|
8
|
+
entryContentDefaultExportHook: (appName) => `export default handle(${appName})`
|
|
9
|
+
},
|
|
10
|
+
...pluginOptions
|
|
11
|
+
}),
|
|
12
|
+
name: "@hono/vite-build/netlify-functions"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
netlifyFunctionsBuildPlugin as default
|
|
17
|
+
};
|
package/dist/base.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type BuildOptions = {
|
|
|
19
19
|
emptyOutDir?: boolean;
|
|
20
20
|
apply?: ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined;
|
|
21
21
|
} & Omit<GetEntryContentOptions, 'entry'>;
|
|
22
|
-
declare const defaultOptions: Required<Omit<BuildOptions, 'entryContentAfterHooks' | 'entryContentBeforeHooks'>>;
|
|
22
|
+
declare const defaultOptions: Required<Omit<BuildOptions, 'entryContentAfterHooks' | 'entryContentBeforeHooks' | 'entryContentDefaultExportHook'>>;
|
|
23
23
|
declare const buildPlugin: (options: BuildOptions) => Plugin;
|
|
24
24
|
|
|
25
25
|
export { BuildOptions, buildPlugin as default, defaultOptions };
|
package/dist/base.js
CHANGED
|
@@ -64,6 +64,7 @@ const buildPlugin = (options) => {
|
|
|
64
64
|
entry: Array.isArray(entry) ? entry : [entry],
|
|
65
65
|
entryContentBeforeHooks: options.entryContentBeforeHooks,
|
|
66
66
|
entryContentAfterHooks: options.entryContentAfterHooks,
|
|
67
|
+
entryContentDefaultExportHook: options.entryContentDefaultExportHook,
|
|
67
68
|
staticPaths
|
|
68
69
|
});
|
|
69
70
|
}
|
package/dist/entry/index.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ type GetEntryContentOptions = {
|
|
|
6
6
|
entry: string[];
|
|
7
7
|
entryContentBeforeHooks?: EntryContentHook[];
|
|
8
8
|
entryContentAfterHooks?: EntryContentHook[];
|
|
9
|
+
/**
|
|
10
|
+
* Explicitly specify the default export for the app. Make sure your export
|
|
11
|
+
* incorporates the app passed as the `appName` argument.
|
|
12
|
+
*
|
|
13
|
+
* @default `export default ${appName}`
|
|
14
|
+
*/
|
|
15
|
+
entryContentDefaultExportHook?: EntryContentHook;
|
|
9
16
|
staticPaths?: string[];
|
|
10
17
|
};
|
|
11
18
|
declare const getEntryContent: (options: GetEntryContentOptions) => Promise<string>;
|
package/dist/entry/index.js
CHANGED
|
@@ -42,7 +42,8 @@ const getEntryContent = async (options) => {
|
|
|
42
42
|
if (!added) {
|
|
43
43
|
throw new Error("Can't import modules from [${globStr}]")
|
|
44
44
|
}`;
|
|
45
|
-
const
|
|
45
|
+
const defaultExportHook = options.entryContentDefaultExportHook ?? (() => "export default mainApp");
|
|
46
|
+
return `import { Hono } from 'hono'
|
|
46
47
|
const mainApp = new Hono()
|
|
47
48
|
|
|
48
49
|
${await hooksToString("mainApp", options.entryContentBeforeHooks)}
|
|
@@ -51,8 +52,7 @@ ${appStr}
|
|
|
51
52
|
|
|
52
53
|
${await hooksToString("mainApp", options.entryContentAfterHooks)}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
return mainAppStr;
|
|
55
|
+
${await hooksToString("mainApp", [defaultExportHook])}`;
|
|
56
56
|
};
|
|
57
57
|
export {
|
|
58
58
|
getEntryContent
|
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.3.0",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"types": "./dist/adapter/cloudflare-workers/index.d.ts",
|
|
37
37
|
"import": "./dist/adapter/cloudflare-workers/index.js"
|
|
38
38
|
},
|
|
39
|
+
"./netlify-functions": {
|
|
40
|
+
"types": "./dist/adapter/netlify-functions/index.d.ts",
|
|
41
|
+
"import": "./dist/adapter/netlify-functions/index.js"
|
|
42
|
+
},
|
|
39
43
|
"./deno": {
|
|
40
44
|
"types": "./dist/adapter/deno/index.d.ts",
|
|
41
45
|
"import": "./dist/adapter/deno/index.js"
|
|
@@ -57,6 +61,9 @@
|
|
|
57
61
|
],
|
|
58
62
|
"cloudflare-workers": [
|
|
59
63
|
"./dist/adapter/cloudflare-workers/index.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"netlify-functions": [
|
|
66
|
+
"./dist/adapter/netlify-functions/index.d.ts"
|
|
60
67
|
]
|
|
61
68
|
}
|
|
62
69
|
},
|
|
@@ -77,7 +84,7 @@
|
|
|
77
84
|
"publint": "^0.1.12",
|
|
78
85
|
"rimraf": "^5.0.1",
|
|
79
86
|
"tsup": "^7.2.0",
|
|
80
|
-
"vite": "^5.4.
|
|
87
|
+
"vite": "^5.4.12",
|
|
81
88
|
"vitest": "^2.1.1"
|
|
82
89
|
},
|
|
83
90
|
"peerDependencies": {
|