Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Fragment symbol comparable across module instances #36

Merged
merged 1 commit into from Jan 14, 2022

Conversation

spiffytech
Copy link
Member

When debugging Forgo using npm link, Vite's pre-bundling optimization executes the forgo module twice (Vite bug, Svelte bug with workarounds). 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.

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.
@jeswin jeswin merged commit 2bd8293 into forgojs:main Jan 14, 2022
@jeswin
Copy link
Member

jeswin commented Jan 14, 2022

Makes sense. Thanks!
Published 2.1.1 with your pull request.

Two tests fail because the re-ordering issue you reported earlier is still unfixed (I haven't found enough time yet, and it's a lot of work). Please ignore those failing tests for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants