mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:36:22 -04:00
fix(web): map Node-only specifiers to false via browser field
Browser bundlers (esbuild, webpack, vite, rollup) statically discover the
`await import("fs/promises")` and `await import("module")` calls in the
shipped ESM bundle and try to resolve them, even though both sit in
Node-only branches that never execute in a browser.
Adding a top-level `browser` field tells bundlers to substitute empty
stubs for these specifiers when targeting the browser. The runtime gates
(`globalThis.process?.versions.node` and `ENVIRONMENT_IS_NODE`) already
prevent the stubs from ever being invoked.
Fixes #5545.
This commit is contained in:
parent
ac17c8d003
commit
0be5f898ad
|
|
@ -43,6 +43,11 @@
|
|||
},
|
||||
"./debug/web-tree-sitter.wasm": "./debug/web-tree-sitter.wasm"
|
||||
},
|
||||
"browser": {
|
||||
"fs": false,
|
||||
"fs/promises": false,
|
||||
"module": false
|
||||
},
|
||||
"types": "web-tree-sitter.d.ts",
|
||||
"keywords": [
|
||||
"incremental",
|
||||
|
|
|
|||
Loading…
Reference in a new issue