@hono/vite-build 1.6.2 → 1.7.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
@@ -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
 
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
  },
@@ -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 };
@@ -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 'hono'
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.6.2",
4
+ "version": "1.7.0",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
7
7
  "type": "module",