TypeScript Core#8861
Conversation
| "packageManager": { | ||
| "name": "npm" | ||
| } | ||
| } |
There was a problem hiding this comment.
Very strange choice. How about simply "version": ">= 20"?
There was a problem hiding this comment.
Node.JS has this unusual convention that odd-numbered versions are not stable and become unsupported after 6 months. Only even-numbered versions receive continued long-term support (bugfixes & security updates) after ‘current’ development, which is why i put "^20 || ^22 || ^24 || ^26".
Luckily this is about to change starting in v27 (planned April 2027) where:
Starting with Node.js 27, the release cycle will be annual and every major version will move to LTS status after its six-month Current phase (and six additional months of Alpha phase).
There was a problem hiding this comment.
Setting a minimum version is pretty standard practice. You do it once and then forget about it. In your case, though, you'll need to update the list every time a new major node.js version comes out! And why does it matter whether the version is stable or not stable? It doesn't suddenly break anything.
In addition, there are users who rarely update, while others use only the latest version of node (which may not be included in that list).
There was a problem hiding this comment.
Fair enough, and agreed, it'd be better to set it once and only update once a version reaches end-of-life. I'll set the minimum to >= 22
| target_link_libraries(binaryen_js PRIVATE "-sEXPORT_ES6") | ||
| endif() | ||
| target_link_libraries(binaryen_js PRIVATE "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii,getExceptionMessage") | ||
| target_link_libraries(binaryen_js PRIVATE "-sEXPORTED_RUNTIME_METHODS=out,err,HEAP8,HEAPU8,HEAP32,HEAPU32,stackSave,stackRestore,stackAlloc,UTF8ToString,stringToAscii,stringToUTF8OnStack,getExceptionMessage") |
There was a problem hiding this comment.
Why we need extended exported symbols? I haven't seen them being used. Also js-bindings works without all of them normally.
There was a problem hiding this comment.
Most of these symbols aren't needed in this PR but they will be needed in future code migration (example links below are from #8826):
outwill be used in emitAsmJS- i can remove
err, looks like it's not used in the TS anywhere - all the heaps are used in various functions, e.g.:
- HEAP8 in DataSegment
- HEAPU8, HEAP32, & HEAPU32 in emitBinary
stackSave,stackRestore, andstackAllocwill be needed in utilitiesUTF8ToString,stringToAscii, andstringToUTF8OnStackfor anything using javascript strings (e.g. parseText)
The reason the JS bindings work without them is because the current post.js file is appended to (i think) the WASM bindings before Emscripten processes them; that's the --post-js flag given on line 562. that's why the JS code is able to access the symbols in Emscripten's codebase without being exported. but now that the Emscripten build happens before calling await Binaryen(), we need those symbols exported on the object, so they need to be added to EXPORTED_RUNTIME_METHODS. (see the comment in binaryen_js.d.ts
|
TODO:
|
The first of several PRs in an attempt to break up #8826 into smaller parts. This PR sets up core typescript functionality and ports over only the top-level types, constants, and enums of the JS API.
Changes:
ts/folder with README.md, package.json, tsconfig.json, and other project filesCMakeLists.txt, exporting needed variables & methods (likeHEAP8) from Emscripten into the JS buildts/src/-pre.tsimports the Emscripten-builtBinaryenfunction, calls and awaits it, and exports that as an internal object calledBinaryenObj(AssemblyScript calls this objectbinaryenand exports that publicly).ts/src/**: the typescript library sits on top of the Emscripten artifact. it accesses the WASM bindings onBinaryenObjimported from-pre.ts.ts/src/binaryen.tsfor users, exporting all the parts of the public-facing API. Users use a namespace import instead of a default import:users will still use the same API (
binaryen.ExpressionRef,binaryen.i32,binaryen.Module, etc.)ts/tests/. hopefully this will take some of the weight off the python testsNon-Changes:
API Deprecations (see
ts/src/-deprecations.tsfor full list; will evolve with more PRs):binaryen.Features→binaryen.Feature)binaryen.Features, but there is a doc-comment@deprecatedwarning for intellisense support)Get started:
See
ts/package.json,ts/README.md, andts/docs/API-Overview.md(in this PR) for details.