fix #3521 Generated PR message below --- ## Problem Island files named after JavaScript global objects (e.g., Map.tsx, `Set.tsx`, `Array.tsx`, `Promise.tsx`) cause runtime errors. The generated boot code uses object shorthand syntax that resolves to the global constructor instead of the imported component: ```javascript import Map from "/islands/Map.tsx"; boot({Map}, props); // {Map} resolves to global Map constructor ``` This results in `TypeError: Map is not a constructor` when the runtime attempts to instantiate islands. ## Solution Generate safe prefixed variable names (`__FRSH_ISLAND_N`) for island imports and use explicit object property syntax to preserve the original island names: ```javascript import __FRSH_ISLAND_0 from "/islands/Map.tsx"; boot({"Map":__FRSH_ISLAND_0}, props); ``` This approach: - Eliminates variable shadowing in all contexts (no scope collisions) - Preserves original island names in HTML markers, error messages, and runtime registry - Allows any valid filename without restrictions - Follows existing Fresh conventions for generated identifiers ## Changes - preact_hooks.ts: Updated client-side boot script generation - dev_build_cache.ts: Updated server-side snapshot generation - Added integration tests for both Builder and Vite build systems - Added documentation comment explaining why globals aren't in `JS_RESERVED` ## Testing Both tests verify that islands named after globals build successfully and use safe variable names in generated code. Tests confirm the bug is detected when fixes are reverted.
Fresh vite plugin
Vite plugin for Fresh.
Usage
- Run
deno install jsr:@fresh/plugin-vite npm:vite - Ensure that your
deno.jsonhas thefreshimport mapping:
{
"imports": {
"fresh": "jsr:@fresh/core"
}
}
- Update your
vite.config.tsfile:
import { defineConfig } from "vite";
+ import { fresh } from "@fresh/plugin-vite";
export default defineConfig({
plugins: [
+ fresh(),
],
});
- Update your deno tasks respectively:
- Dev:
vite - Build:
vite build
More information on the Fresh documentation .