bennyp
bennyp23h ago

Bundling node-tree-sitter

Hello there! I'm working on a language server written in Deno TS. I'd like to bundle it with node-tree-sitter, and I'm using esbuild as the docs recommend., but node-tree-sitter doesn't bundle nicely. https://github.com/bennypowers/design-tokens-language-server/issues/1#issuecomment-2776935304 If you have some ideas how I might work around this, I'd appreciate your input. Maybe with a dynamic import and --include?
GitHub
codeActions: rewrite-refactor · Issue #1 · bennypowers/design-tok...
single char range: if cursor is on a design token in a var() call, remove the fallback if it exists, add the fallback if it doesn't, or cycle the fallback between light-dark values, if it's...
2 Replies
bennyp
bennypOP23h ago
with this esbuild call, I can run compile to completion
await esbuild.build({
plugins: [...denoPlugins()],
loader: {
".node": "copy"
},
entryPoints: ['src/main.ts'],
outfile: './dist/main.js',
bundle: true,
format: 'esm',
});
await esbuild.build({
plugins: [...denoPlugins()],
loader: {
".node": "copy"
},
entryPoints: ['src/main.ts'],
outfile: './dist/main.js',
bundle: true,
format: 'esm',
});
however:
Language server error: design-tokens-language-server

oneshot canceled
-- stderr--
error: Uncaught (in promise) Error: Dynamic require of "fs" is not supported
throw Error('Dynamic require of "' + x + '" is not supported');
^
at file:///tmp/deno-compile-design-tokens-language-server/main.js:11:9
at node_modules/.deno/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js (file:///tmp/deno-compile-design-tokens-language-server/main.js:6092:15)
at __require3 (file:///tmp/deno-compile-design-tokens-language-server/main.js:22:50)
at node_modules/.deno/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js (file:///tmp/deno-compile-design-tokens-language-server/main.js:6265:25)
at __require3 (file:///tmp/deno-compile-design-tokens-language-server/main.js:22:50)
at node_modules/.deno/node-tree-sitter@0.0.1/node_modules/node-tree-sitter/index.js (file:///tmp/deno-compile-design-tokens-language-server/main.js:6273:19)
at __require3 (file:///tmp/deno-compile-design-tokens-language-server/main.js:22:50)
at file:///tmp/deno-compile-design-tokens-language-server/main.js:31123:34
Language server error: design-tokens-language-server

oneshot canceled
-- stderr--
error: Uncaught (in promise) Error: Dynamic require of "fs" is not supported
throw Error('Dynamic require of "' + x + '" is not supported');
^
at file:///tmp/deno-compile-design-tokens-language-server/main.js:11:9
at node_modules/.deno/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js (file:///tmp/deno-compile-design-tokens-language-server/main.js:6092:15)
at __require3 (file:///tmp/deno-compile-design-tokens-language-server/main.js:22:50)
at node_modules/.deno/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js (file:///tmp/deno-compile-design-tokens-language-server/main.js:6265:25)
at __require3 (file:///tmp/deno-compile-design-tokens-language-server/main.js:22:50)
at node_modules/.deno/node-tree-sitter@0.0.1/node_modules/node-tree-sitter/index.js (file:///tmp/deno-compile-design-tokens-language-server/main.js:6273:19)
at __require3 (file:///tmp/deno-compile-design-tokens-language-server/main.js:22:50)
at file:///tmp/deno-compile-design-tokens-language-server/main.js:31123:34
bennyp
bennypOP22h ago
We've got https://deno.land/x/deno_tree_sitter@0.2.8.5 BUT
✘ [ERROR] Relative import path "fs" not prefixed with / or ./ or ../ and not in import map from "https://deno.land/x/deno_tree_sitter@0.2.8.5/tree_sitter.js" [plugin deno-resolver]

https://deno.land/x/deno_tree_sitter@0.2.8.5/tree_sitter.js:2075:36:
2075 │ let r = require("fs")
╵ ~~~~
✘ [ERROR] Relative import path "fs" not prefixed with / or ./ or ../ and not in import map from "https://deno.land/x/deno_tree_sitter@0.2.8.5/tree_sitter.js" [plugin deno-resolver]

https://deno.land/x/deno_tree_sitter@0.2.8.5/tree_sitter.js:2075:36:
2075 │ let r = require("fs")
╵ ~~~~
Deno
deno_tree_sitter@0.2.8.5 | Deno
💾 📦 ✅ Use the web-tree-sitter in Deno!

Did you find this page helpful?