ikatyang / tree-sitter-yaml

YAML grammar for tree-sitter
https://ikatyang.github.io/tree-sitter-yaml/
MIT License
93 stars 38 forks source link

Extreme WASM size #5

Closed char0n closed 3 years ago

char0n commented 3 years ago

Hi @ikatyang,

First of all thank you for this YAML grammar for tree-sitter. I wanted to ask about the size of src/parser.c size. It seems a little bit extreme at 940K. After the parser grammar is compiled to WASM size is 719,3 KiB (736 604 bytes).

Are you aware of this? Can we do something about it?

Thanks!

ikatyang commented 3 years ago

Hi, I recompiled tree-sitter-yaml.wasm with tree-sitter-cli@0.16.7, it is now 135KB (b26d567).

char0n commented 3 years ago

Steps To Reproduce

$ cd /tmp
$ npm i tree-sitter-cli@0.16.7
$ npm i npm i tree-sitter-yaml@0.1.0
$ ./node_modules/.bin/tree-sitter build-wasm ./node_modules/tree-sitter-yaml/
$ du -h tree-sitter-yaml.wasm

720K tree-sitter-yaml.wasm

I'm on Ubuntu Linux based system. Here is basically a POC repo that is prebuilding all the WAMS(s) for tree-sitter and is getting the same size of YAML WASM.

ikatyang commented 3 years ago

The parser.c shipped with npm:tree-sitter-yaml@0.1.0 is generated by tree-sitter-cli@0.15.7, you probably need to tree-sitter generate before tree-sitter build-wasm to get the 135KB wasm.

char0n commented 3 years ago

@ikatyang right, that decreased the size to expected 135KB WASM. Thanks