Merge pull request #1913 from J3RN/browser-fixes

Allow web-tree-sitter to work with Emscripten 3
This commit is contained in:
Max Brunsfeld 2022-11-15 17:03:31 -08:00 committed by GitHub
commit b31f9e6e90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View file

@ -1 +1 @@
2.0.24
3.1.25

View file

@ -83,6 +83,8 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu
"-s",
"NODEJS_CATCH_EXIT=0",
"-s",
"NODEJS_CATCH_REJECTION=0",
"-s",
&format!("EXPORTED_FUNCTIONS=[\"_tree_sitter_{}\"]", grammar_name),
"-fno-exceptions",
"-I",

View file

@ -14,6 +14,7 @@
"__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev",
"__ZdlPv",
"__Znwm",
"___cxa_atexit",
"_abort",
"_iswalnum",
"_iswalpha",
@ -24,6 +25,7 @@
"_memcmp",
"_memcpy",
"_memmove",
"_memset",
"_strlen",
"_towupper",

View file

@ -77,6 +77,8 @@ fi
mkdir -p target/scratch
runtime_methods='stringToUTF16','AsciiToString'
# Use emscripten to generate `tree-sitter.js` and `tree-sitter.wasm`
# in the `target/scratch` directory
$emcc \
@ -88,6 +90,7 @@ $emcc \
-s NODEJS_CATCH_EXIT=0 \
-s NODEJS_CATCH_REJECTION=0 \
-s EXPORTED_FUNCTIONS=@${web_dir}/exports.json \
-s EXPORTED_RUNTIME_METHODS=$runtime_methods \
$emscripten_flags \
-fno-exceptions \
-std=c99 \