Skip to content

Update to documentation - #5

Merged
GunnerGuyven merged 3 commits into
milahu:masterfrom
GunnerGuyven:master
Jan 20, 2026
Merged

GunnerGuyven merged 3 commits into
milahu:masterfrom
GunnerGuyven:master

Conversation

@GunnerGuyven

@GunnerGuyven GunnerGuyven commented Jan 20, 2026 •

Copy link
Copy Markdown
Collaborator

web-tree-sitter after 0.26 has changed both it's helper wasm filename, and tweaked how it is notified to javascript that is more bundler-friendly than before. As a result of this, our previous bundler-helper code that served tree-sitter.wasm to the bundle if it was noticed in the project (now renamed to web-tree-sitter.wasm) was both broken and finally unneeded.

The seemingly correct way to handle web-tree-sitter now is to allow it to bundle on it's own (vite build sees it and picks it up automatically), and accept that while it still doesn't serve properly in vite's dev mode, this can be overcome with a vite settings addition:

// vite.config.ts
export default defineConfig({
	// ...
	// following is required for web-tree-sitter.wasm to appear in dev-mode
	optimizeDeps: { exclude: ["web-tree-sitter"] },
})

This tells vite to disable it's internal caching of that particular package, which enables the .wasm to be found by code running in dev-mode. I don't believe this impacts production builds at all.

This PR does not include any code changes (other than version bumps), this merely adds this setting to the example documentation in the README.

@GunnerGuyven GunnerGuyven changed the title Adds documentation Update to documentation Jan 20, 2026
@milahu

milahu commented Jan 20, 2026

Copy link
Copy Markdown
Owner

it still doesn't serve properly in vite's dev mode

sounds like a bug in vite. is there a github issue?

@GunnerGuyven

Copy link
Copy Markdown
Collaborator Author

I haven't seen one, but I will look. It is peculiar that vite fails to resolve the .wasm in dev-mode, but puts it in the right place during build. I don't know what they expect to be done for a situation like this. Disabling vite's dev-mode caching for this package works because vite refers to it in-place instead of moving it to the vite cache (it is a relative URL to the .js file that looks up the .wasm file).

@GunnerGuyven

Copy link
Copy Markdown
Collaborator Author

I think this is it. vitejs/vite#8427

@milahu

milahu commented Jan 20, 2026 •

Copy link
Copy Markdown
Owner

so vite has been broken for 3 years 0__o
is this fixed by vitejs/vite#14260?

does this work with rollup?

this should be mentioned in readme

 // following is required for web-tree-sitter.wasm to appear in dev-mode
 optimizeDeps: { exclude: ["web-tree-sitter"] },

@GunnerGuyven

Copy link
Copy Markdown
Collaborator Author

Vite's position seems to be 'wontfix' until they finish their giant migration to the rolldown backend (which is years late at this point, and hilariously has the same bug vitejs/rolldown-vite#362 ). We seem to be in agreement that this should be in the documentation, so I'll merge this PR if you do agree.

@milahu

milahu commented Jan 20, 2026

Copy link
Copy Markdown
Owner

We seem to be in agreement that this should be in the documentation

i mean, the vite issue should be linked in readme

@GunnerGuyven

Copy link
Copy Markdown
Collaborator Author

I understand. I'll add that momentarily.

@GunnerGuyven

Copy link
Copy Markdown
Collaborator Author

new text

 // following is required for web-tree-sitter.wasm to appear in dev-mode
 // until https://github.com/vitejs/vite/issues/8427 is addressed
 optimizeDeps: { exclude: ["web-tree-sitter"] },

@GunnerGuyven
GunnerGuyven merged commit 3258d69 into milahu:master Jan 20, 2026
@milahu

milahu commented Jan 20, 2026

Copy link
Copy Markdown
Owner

thx

can you please also add this to
examples/deno/vite.config.ts
examples/pnpm/vite.config.mts
examples/solidjs/src/vite.config.js
so users can just copy-paste these files

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.

2 participants