Will this run in the browser (WASM)? #458
-
|
Since the announcement does not mention WASM, will running typescript-go in the browser will be officially supported? I guess this will be a requirement for TypeScript Playground and other users of |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 16 replies
-
Yes! |
Beta Was this translation helpful? Give feedback.
-
|
It would be nice to see more details on the work~ |
Beta Was this translation helpful? Give feedback.
-
|
If WASM is yes, I just want to clarify: This allows us to compile TypeScript into Go source? This isn't just for optimizing the compiler/vscode, right? If so, are there any plans to allow Go packages to be imported into TypeScript? Perhaps by generating At our company we use both TypeScript and Go. We mostly use Go on the backend, but we have team members who are more comfortable with TypeScript. |
Beta Was this translation helpful? Give feedback.
-
|
I’m concerned about tree-shaking. Many projects, like ts-blank-space, use only part of the TypeScript compiler API, and with tree-shaking, the bundle size can be significantly reduced compared to including the full TypeScript bundle. I have developed an online TypeScript REPL that utilizes the TypeScript compiler API in the browser (repository here). After tree-shaking, it adds approximately 3MB to the bundle, which is acceptable in terms of load time since I use dynamic import along with a progress bar. I wonder if the Go port can maintain this size—if the bundle grows to around 15MB, it would be a bit large for such a simple use case. |
Beta Was this translation helpful? Give feedback.
-
|
Would it be possible to provide a set of slim WASM distributions for different tasks? For example, some WASM users who only need to strip TS to JS, may not want to incur the size of the typechecker/LSP (emit-only distribution). Conversely, users who need the compiler for LSP purposes won't need emit (check-only distribution). And some users might want just the parser (parser-only distribution). The CLI/watch mode could be omitted from all but the full distribution. I'd imagine this would mitigate the tree-shaking problem because I'd imagine tree shaking would converge into a small number of modes (parse-only, parse-emit-only, parse-check-only, parse-emit-check-only, or full). It's not as if you can have tree-shaking pull in half of a parser or half of a typechecker. Users could select the WASM distribution that matches their use case and shave a few MBs off download times. |
Beta Was this translation helpful? Give feedback.
Yes!