honox 0.1.18 → 0.1.20

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
@@ -634,11 +634,12 @@ Write `app/style.css`:
634
634
  @tailwind utilities;
635
635
  ```
636
636
 
637
- Import it in a renderer file:
637
+ Import it in a renderer file. Using the `Link` component will refer to the correct CSS file path after it is built.
638
638
 
639
639
  ```tsx
640
640
  // app/routes/_renderer.tsx
641
641
  import { jsxRenderer } from 'hono/jsx-renderer'
642
+ import { Link } from 'honox/server'
642
643
 
643
644
  export default jsxRenderer(({ children }) => {
644
645
  return (
@@ -646,11 +647,7 @@ export default jsxRenderer(({ children }) => {
646
647
  <head>
647
648
  <meta charset='UTF-8' />
648
649
  <meta name='viewport' content='width=device-width, initial-scale=1.0' />
649
- {import.meta.env.PROD ? (
650
- <link href='/static/assets/style.css' rel='stylesheet' />
651
- ) : (
652
- <link href='/app/style.css' rel='stylesheet' />
653
- )}
650
+ <Link href='/app/style.css' rel='stylesheet' />
654
651
  </head>
655
652
  <body>{children}</body>
656
653
  </html>
@@ -670,9 +667,6 @@ export default defineConfig(({ mode }) => {
670
667
  build: {
671
668
  rollupOptions: {
672
669
  input: ['/app/style.css'],
673
- output: {
674
- assetFileNames: 'static/assets/[name].[ext]',
675
- },
676
670
  },
677
671
  },
678
672
  }
@@ -1,8 +1,8 @@
1
1
  import { render } from "hono/jsx/dom";
2
2
  import { jsx as jsxFn } from "hono/jsx/dom/jsx-runtime";
3
3
  import {
4
- COMPONENT_NAME,
5
4
  COMPONENT_EXPORT,
5
+ COMPONENT_NAME,
6
6
  DATA_HONO_TEMPLATE,
7
7
  DATA_SERIALIZED_PROPS
8
8
  } from "../constants.js";
@@ -1,3 +1,6 @@
1
1
  export { HasIslands } from './has-islands.js';
2
2
  export { Script } from './script.js';
3
+ export { Link } from './link.js';
3
4
  import 'vite';
5
+ import 'hono/jsx';
6
+ import 'hono/jsx/jsx-runtime';
@@ -1,6 +1,8 @@
1
1
  import { HasIslands } from "./has-islands.js";
2
2
  import { Script } from "./script.js";
3
+ import { Link } from "./link.js";
3
4
  export {
4
5
  HasIslands,
6
+ Link,
5
7
  Script
6
8
  };
@@ -0,0 +1,11 @@
1
+ import { FC } from 'hono/jsx';
2
+ import { JSX } from 'hono/jsx/jsx-runtime';
3
+ import { Manifest } from 'vite';
4
+
5
+ type Options = {
6
+ manifest?: Manifest;
7
+ prod?: boolean;
8
+ } & JSX.IntrinsicElements['link'];
9
+ declare const Link: FC<Options>;
10
+
11
+ export { Link };
@@ -0,0 +1,35 @@
1
+ import { Fragment, jsx } from "hono/jsx/jsx-runtime";
2
+ const Link = async (options) => {
3
+ let { href, prod, manifest, ...rest } = options;
4
+ if (href) {
5
+ if (prod ?? import.meta.env.PROD) {
6
+ if (!manifest) {
7
+ const MANIFEST = import.meta.glob("/dist/.vite/manifest.json", {
8
+ eager: true
9
+ });
10
+ for (const [, manifestFile] of Object.entries(MANIFEST)) {
11
+ if (manifestFile["default"]) {
12
+ manifest = manifestFile["default"];
13
+ break;
14
+ }
15
+ }
16
+ }
17
+ if (manifest) {
18
+ const assetInManifest = manifest[href.replace(/^\//, "")];
19
+ if (assetInManifest) {
20
+ if (href.startsWith("/")) {
21
+ return /* @__PURE__ */ jsx("link", { href: `/${assetInManifest.file}`, ...rest });
22
+ }
23
+ return /* @__PURE__ */ jsx("link", { href: assetInManifest.file, ...rest });
24
+ }
25
+ }
26
+ return /* @__PURE__ */ jsx(Fragment, {});
27
+ } else {
28
+ return /* @__PURE__ */ jsx("link", { href, ...rest });
29
+ }
30
+ }
31
+ return /* @__PURE__ */ jsx("link", { ...rest });
32
+ };
33
+ export {
34
+ Link
35
+ };
@@ -2,7 +2,10 @@ export { createApp } from './with-defaults.js';
2
2
  export { ServerOptions } from './server.js';
3
3
  export { HasIslands } from './components/has-islands.js';
4
4
  export { Script } from './components/script.js';
5
+ export { Link } from './components/link.js';
5
6
  import 'hono';
6
7
  import 'hono/types';
7
8
  import '../constants.js';
8
9
  import 'vite';
10
+ import 'hono/jsx';
11
+ import 'hono/jsx/jsx-runtime';
@@ -65,9 +65,10 @@ const createApp = (options) => {
65
65
  subApp.all("*", rendererDefault);
66
66
  }
67
67
  });
68
- const middlewareFile = Object.keys(MIDDLEWARE_FILE).find(
69
- (x) => new RegExp(dir + "/_middleware.tsx?").test(x)
70
- );
68
+ const middlewareFile = Object.keys(MIDDLEWARE_FILE).find((x) => {
69
+ const replacedDir = dir.replace("[", "\\[").replace("]", "\\]");
70
+ return new RegExp(replacedDir + "/_middleware.tsx?").test(x);
71
+ });
71
72
  if (middlewareFile) {
72
73
  const middleware = MIDDLEWARE_FILE[middlewareFile];
73
74
  if (middleware.default) {
@@ -1,8 +1,10 @@
1
+ import * as hono_jsx_jsx_dev_runtime from 'hono/jsx/jsx-dev-runtime';
2
+
1
3
  declare const HonoXIsland: ({ componentName, componentExport, Component, props, }: {
2
4
  componentName: string;
3
5
  componentExport: string;
4
6
  Component: Function;
5
7
  props: any;
6
- }) => JSX.Element;
8
+ }) => hono_jsx_jsx_dev_runtime.JSX.Element;
7
9
 
8
10
  export { HonoXIsland };
@@ -1 +1,2 @@
1
1
  export { HonoXIsland } from './honox-island.js';
2
+ import 'hono/jsx/jsx-dev-runtime';
@@ -6,30 +6,30 @@ import { parse } from "@babel/parser";
6
6
  import _traverse from "@babel/traverse";
7
7
  const traverse = _traverse.default ?? _traverse;
8
8
  import {
9
+ blockStatement,
10
+ conditionalExpression,
11
+ exportDefaultDeclaration,
12
+ exportNamedDeclaration,
13
+ exportSpecifier,
14
+ functionExpression,
9
15
  identifier,
16
+ importDeclaration,
17
+ importSpecifier,
10
18
  jsxAttribute,
11
19
  jsxClosingElement,
12
20
  jsxElement,
21
+ jsxExpressionContainer,
13
22
  jsxIdentifier,
14
23
  jsxOpeningElement,
15
- stringLiteral,
16
- variableDeclarator,
17
- variableDeclaration,
18
- functionExpression,
19
- blockStatement,
20
- returnStatement,
21
24
  jsxSpreadAttribute,
22
- jsxExpressionContainer,
23
- exportDefaultDeclaration,
24
- conditionalExpression,
25
25
  memberExpression,
26
- importDeclaration,
27
- importSpecifier,
28
- exportNamedDeclaration,
29
- exportSpecifier
26
+ returnStatement,
27
+ stringLiteral,
28
+ variableDeclaration,
29
+ variableDeclarator
30
30
  } from "@babel/types";
31
31
  import { parse as parseJsonc } from "jsonc-parser";
32
- import { matchIslandComponentId, isComponentName } from "./utils/path.js";
32
+ import { isComponentName, matchIslandComponentId } from "./utils/path.js";
33
33
  function addSSRCheck(funcName, componentName, componentExport) {
34
34
  const isSSR = memberExpression(
35
35
  memberExpression(identifier("import"), identifier("meta")),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honox",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -120,7 +120,7 @@
120
120
  "hono": ">=4.*"
121
121
  },
122
122
  "devDependencies": {
123
- "@hono/eslint-config": "^0.0.4",
123
+ "@hono/eslint-config": "^0.0.6",
124
124
  "@mdx-js/rollup": "^3.0.0",
125
125
  "@playwright/test": "^1.42.0",
126
126
  "@types/babel__generator": "^7",
@@ -128,7 +128,7 @@
128
128
  "@types/node": "^20.10.5",
129
129
  "eslint": "^8.56.0",
130
130
  "glob": "^10.3.10",
131
- "hono": "^4.3.9",
131
+ "hono": "^4.4.3",
132
132
  "np": "7.7.0",
133
133
  "prettier": "^3.1.1",
134
134
  "publint": "^0.2.7",