Skip to content

Commit b2c4f04

Browse files
fix(vite): island hmr (#3269)
1 parent 62b6205 commit b2c4f04

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

packages/plugin-vite/src/plugins/server_snapshot.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import {
1414
specToName,
1515
UniqueNamer,
1616
} from "fresh/internal-dev";
17-
import { pathWithRoot, type ResolvedFreshViteConfig } from "../utils.ts";
17+
import {
18+
JS_REG,
19+
pathWithRoot,
20+
type ResolvedFreshViteConfig,
21+
} from "../utils.ts";
1822
import * as path from "@std/path";
1923
import { getBuildId } from "./build_id.ts";
2024

@@ -268,7 +272,12 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
268272
name: "fresh:island-resolver",
269273
resolveId(id) {
270274
if (id.startsWith("fresh-island::")) {
271-
const name = id.slice("fresh-island::".length);
275+
let name = id.slice("fresh-island::".length);
276+
277+
if (JS_REG.test(name)) {
278+
name = name.slice(0, name.lastIndexOf("."));
279+
}
280+
272281
const spec = islandSpecByName.get(name);
273282
if (spec !== undefined) return spec;
274283
}

0 commit comments

Comments
 (0)