diff --git a/README.md b/README.md index 88ab24b..f83f87a 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,27 @@ export default jsxRenderer(({ children }) => { }) ``` +If you have a manifest file in `dist/.vite/manifest.json`, you can easily write it using ` - - ) : ( - - )} + + } + } + return <> + } else { + return + } +} diff --git a/src/server/index.ts b/src/server/index.ts index a6be94c..693a5f6 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -1,3 +1,3 @@ export { createApp } from './server.js' export type { ServerOptions } from './server.js' -export { HasIslands } from './components.js' +export * from './components/index.js' diff --git a/src/server/server.ts b/src/server/server.ts index b183183..43ed4a7 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -8,7 +8,6 @@ import { filePathToPath, groupByDirectory, listByDirectory, - pathToDirectoryPath, sortDirectoriesByDepth, } from '../utils/file.js' diff --git a/src/vite/client.ts b/src/vite/client.ts new file mode 100644 index 0000000..83f9cfa --- /dev/null +++ b/src/vite/client.ts @@ -0,0 +1,33 @@ +import type { Plugin } from 'vite' + +type Options = { + jsxImportSource?: string + assetsDir?: string +} + +export const defaultOptions: Options = { + jsxImportSource: 'hono/jsx/dom', + assetsDir: 'static', +} + +function client(options?: Options): Plugin { + return { + name: 'honox-vite-client', + config: () => { + return { + build: { + rollupOptions: { + input: ['/app/client.ts'], + }, + assetsDir: options?.assetsDir ?? defaultOptions.assetsDir, + manifest: true, + }, + esbuild: { + jsxImportSource: options?.jsxImportSource ?? defaultOptions.jsxImportSource, + }, + } + }, + } +} + +export default client diff --git a/src/vite/index.ts b/src/vite/index.ts index 1eb5c2b..60402ce 100644 --- a/src/vite/index.ts +++ b/src/vite/index.ts @@ -5,19 +5,19 @@ import type { PluginOption } from 'vite' import { injectImportingIslands } from './inject-importing-islands.js' import { islandComponents } from './island-components.js' -type HonoXOptions = { +type Options = { islands?: boolean entry?: string devServer?: DevServerOptions external?: string[] } -export const defaultOptions: HonoXOptions = { +export const defaultOptions: Options = { islands: true, entry: path.join(process.cwd(), './app/server.ts'), } -function honox(options?: HonoXOptions): PluginOption[] { +function honox(options?: Options): PluginOption[] { const plugins: PluginOption[] = [] const entry = options?.entry ?? defaultOptions.entry diff --git a/test/hono-jsx/app-script/routes/index.tsx b/test/hono-jsx/app-script/routes/index.tsx new file mode 100644 index 0000000..fe67487 --- /dev/null +++ b/test/hono-jsx/app-script/routes/index.tsx @@ -0,0 +1,19 @@ +import { Script } from '../../../../src/server' + +export default function Hello() { + return ( + + + ' + ) + }) +})