Skip to content

Commit 3f91bd4

Browse files
authored
Make Fragment symbol comparable across module instances
When debugging Forgo using `npm link`, Vite's pre-bundling optimization executes the `forgo` module twice ([Vite bug](vitejs/vite#3910), [Svelte bug with workarounds](sveltejs/vite-plugin-svelte#135 (comment))). It doesn't happen when using the package from npm. This results in different code paths holding references to two different `Fragment` symbols, causing renders to fail because the two symbols aren't comparable using `===`. Using `Symbol.for()` makes all symbols named `FORGO_FRAGMENT` comparable, no matter where they come from. Alternatively, there's a workaround to have Vite disable pre-bundling optimizations for `forgo`, but this patch makes that unnecessary.
1 parent 22e5c70 commit 3f91bd4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export type RenderResult = {
238238
Fragment constructor.
239239
We simply use it as a marker in jsx-runtime.
240240
*/
241-
export const Fragment: unique symbol = Symbol("FORGO_FRAGMENT");
241+
export const Fragment: unique symbol = Symbol.for("FORGO_FRAGMENT");
242242

243243
/*
244244
HTML Namespaces

0 commit comments

Comments
 (0)