Skip to content

Commit afe1424

Browse files
authored
feat: migrate tree-sitter parsers to WASM (web-tree-sitter) (#15)
* feat(synth-go): migrate to web-tree-sitter (WASM) - Update version to 0.3.0 - Replace tree-sitter and tree-sitter-go with web-tree-sitter and tree-sitter-wasms - Implement async-only parser with WASM initialization - Add init() function for pre-initialization - Update all tests to use async/await pattern - Add test for sync parse() throwing error - Add keywords "wasm" and "webassembly" - Makes parser work in browser and non-native environments * feat: migrate tree-sitter parsers to WASM (web-tree-sitter) Migrate 7 tree-sitter-based parsers to use web-tree-sitter (WASM) for cross-platform compatibility. This fixes native module issues when using packages via npx on Windows and other environments without native build tools. Packages migrated: - @sylphx/synth-c: 0.2.2 → 0.3.0 - @sylphx/synth-java: 0.2.2 → 0.3.0 - @sylphx/synth-php: 0.2.2 → 0.3.0 - @sylphx/synth-python: 0.2.2 → 0.3.0 - @sylphx/synth-ruby: 0.2.2 → 0.3.0 - @sylphx/synth-rust: 0.2.2 → 0.3.0 Changes per package: - Replace tree-sitter + tree-sitter-{lang} with web-tree-sitter + tree-sitter-wasms - Implement async-only parser (WASM requires async initialization) - Add init() function for optional pre-initialization - Update all tests to use parseAsync() instead of parse() - parse() now throws error directing users to use parseAsync() BREAKING CHANGE: Synchronous parse() is no longer supported. Use parseAsync() instead.
1 parent 605cbf9 commit afe1424

File tree

29 files changed

+1616
-1378
lines changed

29 files changed

+1616
-1378
lines changed

bun.lockb

-3.47 KB
Binary file not shown.

packages/synth-c/package.json

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
{
2-
"name": "@sylphx/synth-c",
3-
"version": "0.2.3",
4-
"description": "C parser using Synth's universal AST - conversion layer over tree-sitter-c",
5-
"type": "module",
6-
"main": "./dist/index.js",
7-
"types": "./dist/index.d.ts",
8-
"exports": {
9-
".": {
10-
"types": "./dist/index.d.ts",
11-
"import": "./dist/index.js"
12-
}
13-
},
14-
"scripts": {
15-
"test": "bun test",
16-
"test:watch": "bun test --watch",
17-
"build": "bunup",
18-
"prepack": "bun run build"
19-
},
20-
"keywords": [
21-
"c",
22-
"parser",
23-
"ast",
24-
"synth",
25-
"tree-sitter",
26-
"c99",
27-
"c11",
28-
"c17"
29-
],
30-
"author": "SylphX",
31-
"license": "MIT",
32-
"dependencies": {
33-
"@sylphx/synth": "workspace:*",
34-
"tree-sitter": "^0.21.1",
35-
"tree-sitter-c": "^0.23.1"
36-
},
37-
"devDependencies": {
38-
"typescript": "^5.6.0"
39-
}
2+
"name": "@sylphx/synth-c",
3+
"version": "0.3.0",
4+
"description": "C parser using Synth's universal AST - WASM-based, works everywhere",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.js"
12+
}
13+
},
14+
"scripts": {
15+
"test": "bun test",
16+
"test:watch": "bun test --watch",
17+
"build": "bunup",
18+
"prepack": "bun run build"
19+
},
20+
"keywords": [
21+
"c",
22+
"parser",
23+
"ast",
24+
"synth",
25+
"tree-sitter",
26+
"wasm",
27+
"webassembly",
28+
"c99",
29+
"c11",
30+
"c17"
31+
],
32+
"author": "SylphX",
33+
"license": "MIT",
34+
"dependencies": {
35+
"@sylphx/synth": "workspace:*",
36+
"tree-sitter-wasms": "^0.1.11",
37+
"web-tree-sitter": "^0.24.3"
38+
},
39+
"devDependencies": {
40+
"typescript": "^5.6.0"
41+
}
4042
}

packages/synth-c/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
* @packageDocumentation
88
*/
99

10-
export { CParser, createParser, parse, parseAsync } from './parser.js'
10+
export { CParser, createParser, init, parse, parseAsync } from './parser.js'
1111
export * from './types.js'

0 commit comments

Comments
 (0)