honox 0.1.31 → 0.1.33

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.
@@ -1,4 +1,5 @@
1
1
  import { Fragment, jsx } from "hono/jsx/jsx-runtime";
2
+ import { ensureTrailngSlash } from "../utils/path";
2
3
  const Link = (options) => {
3
4
  let { href, prod, manifest, ...rest } = options;
4
5
  if (href) {
@@ -18,7 +19,13 @@ const Link = (options) => {
18
19
  const assetInManifest = manifest[href.replace(/^\//, "")];
19
20
  if (assetInManifest) {
20
21
  if (href.startsWith("/")) {
21
- return /* @__PURE__ */ jsx("link", { href: `/${assetInManifest.file}`, ...rest });
22
+ return /* @__PURE__ */ jsx(
23
+ "link",
24
+ {
25
+ href: `${ensureTrailngSlash(import.meta.env.BASE_URL)}${assetInManifest.file}`,
26
+ ...rest
27
+ }
28
+ );
22
29
  }
23
30
  return /* @__PURE__ */ jsx("link", { href: assetInManifest.file, ...rest });
24
31
  }
@@ -1,4 +1,5 @@
1
1
  import { Fragment, jsx } from "hono/jsx/jsx-runtime";
2
+ import { ensureTrailngSlash } from "../utils/path.js";
2
3
  import { HasIslands } from "./has-islands.js";
3
4
  const Script = (options) => {
4
5
  const src = options.src;
@@ -23,7 +24,7 @@ const Script = (options) => {
23
24
  {
24
25
  type: "module",
25
26
  async: !!options.async,
26
- src: `/${scriptInManifest.file}`,
27
+ src: `${ensureTrailngSlash(import.meta.env.BASE_URL)}${scriptInManifest.file}`,
27
28
  nonce: options.nonce
28
29
  }
29
30
  ) });
@@ -0,0 +1,3 @@
1
+ declare const ensureTrailngSlash: (path: string) => string;
2
+
3
+ export { ensureTrailngSlash };
@@ -0,0 +1,6 @@
1
+ const ensureTrailngSlash = (path) => {
2
+ return path.endsWith("/") ? path : path + "/";
3
+ };
4
+ export {
5
+ ensureTrailngSlash
6
+ };
@@ -162,19 +162,20 @@ function islandComponents(options) {
162
162
  configResolved: async (config) => {
163
163
  root = config.root;
164
164
  if (!reactApiImportSource) {
165
- const tsConfigPath = path.resolve(process.cwd(), "tsconfig.json");
166
- const denoJsonPath = path.resolve(process.cwd(), "deno.json");
165
+ const tsConfigFiles = ["deno.json", "deno.jsonc", "tsconfig.json"];
167
166
  let tsConfigRaw;
168
- try {
169
- tsConfigRaw = await fs.readFile(denoJsonPath, "utf8");
170
- } catch (error1) {
167
+ for (const tsConfigFile of tsConfigFiles) {
171
168
  try {
169
+ const tsConfigPath = path.resolve(process.cwd(), tsConfigFile);
172
170
  tsConfigRaw = await fs.readFile(tsConfigPath, "utf8");
173
- } catch (error2) {
174
- console.warn("Cannot find neither tsconfig.json nor deno.json", error1, error2);
175
- return;
171
+ break;
172
+ } catch {
176
173
  }
177
174
  }
175
+ if (!tsConfigRaw) {
176
+ console.warn("Cannot find tsconfig.json or deno.json(c)");
177
+ return;
178
+ }
178
179
  const tsConfig = parseJsonc(tsConfigRaw);
179
180
  reactApiImportSource = tsConfig?.compilerOptions?.jsxImportSource;
180
181
  if (reactApiImportSource === "hono/jsx/dom") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honox",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -142,9 +142,9 @@
142
142
  "publint": "^0.2.7",
143
143
  "tsup": "^8.1.0",
144
144
  "typescript": "^5.3.3",
145
- "vite": "^5.2.8",
146
- "vite-tsconfig-paths": "^5.0.1",
147
- "vitest": "^1.4.0"
145
+ "vite": "^5.4.12",
146
+ "vite-tsconfig-paths": "^5.1.4",
147
+ "vitest": "^3.0.3"
148
148
  },
149
149
  "engines": {
150
150
  "node": ">=18.14.1"