-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider removing unstable "node:module".stripTypeScriptTypes
to reduce baseline SEA binary size
#57744
Comments
How much does swc add to the binary size? |
Around 3MB |
Also if you drop amaro its not possible to use type stripping either, not just |
It is if it's re-architected to be done ahead of time when creating the executable. Not sure if it's done already, but that's what we do in Deno. An additional benefit is SEAs start faster because they don’t need to transpile on each run. |
There might be some confusion here - node sea doesn't have native typescript support yet. When I implement it, I agree that transpiling the code ahead of time and injecting that code is better than injecting the original code and transpiling on each run. Marco is probably referring to the other existing ways of doing type stripping in node which is separate from node sea. Those won't work if we drop amaro from node. Maybe it could be made to work if node uses amaro as an optional node_modules dep but I'll let Marco answer that. |
Ah, ok I’m not suggesting to remove type stripping from node itself, but just the user facing runtime API for the reasons stated above. |
If we decide not to support typescript in SEA then it makes sense not to include amaro in it and document that |
By not stabilizing, I was implying to remove the public runtime API everywhere, but I didn’t make that explicit. I’ll update the title. |
"node:module".stripTypeScriptTypes
to reduce baseline SEA binary size"node:module".stripTypeScriptTypes
to reduce baseline SEA binary size
I disagree we should remove it from everywhere |
I don’t think that’s viable because over time users will complain that certain things don’t work in SEA. Also, by adding this API, other execution environments other than SEA that offer node compatibility are being bloated (ex. workerd). What’s the issue with users just including the dependency the classic way if they need it? This use case is niche. |
I'm working on other APIs that rely on amaro (#57731) The request of removing an API because of other runtimes feels wild 😄 |
It was a secondary point and not the main point. For example personally in Deno we use swc. |
I see your point, actually having a way to opt-in/opt out some modules in SEA would be beneficial, like amaro, crypto, npm (mentioning those because I know its possible to build node without them). |
That's more reasonable if it's possible and feasible to do that. Side note: this overall trend in JS runtimes to just have built-in APIs for stuff that could be a library is not great for the long term health of the JS ecosystem in my opinion. So much bloat, runtime specific code, and extra complexity across the ecosystem for functionality that could have easily been specified as a dependency and be decoupled from the runtime where it would work in even old versions of node.js. |
Opting out of those modules requires building node from source. While it's definitely possible, SEA builders will find it inconvenient to build node from source. |
Amaro is swc. |
This is more a discussion of allowing SEA to be ahead-of-time and interpolating what |
I think it would be beneficial to consider not stabilizing
stripTypeScriptTypes
and instead require users to specify a dependency on swc or whatever library they wish.Reason: This enables Node single executable applications to stay small and not have every binary have a dependency on swc. Instead users can choose to increase their binary size by specifying a dependency only when they need it and not always.
Sure, current design constraints might mean it's currently always required, but in the future work could be done on Node to make this not the case. For example in Deno our single executable applications are custom smaller binaries that do not include swc and we do all the transpiling work up-front when compiling instead of at runtime.
An alternative to this could be making it opt-in to include this API in single executable applications, but overall I think it's much simpler to just require users to specify a dependency because this is a niche use case and also it makes code work the same way across different versions of Node.
The text was updated successfully, but these errors were encountered: