4 ms·
Ignoring the massive vtable problem for a moment ... If tree shaking is so good, show me how to write something like this: * when targeting browser, use dom
by o11c 2y ago
Ignoring the massive vtable problem for a moment ...
If tree shaking is so good, show me how to write something like this:
* when targeting browser, use dom
* when targeting node, use process/fs
* typescript should bail out if a mixture of APIs is used. That is, the type-checking must be done twice - once for browser-only, once for node-only.
(nodejs is also rather abominable for implementing APIs that really, really only make sense in browsers, like `navigator`, breaking everybody's runtime detection, but all non-browser environments require evil hacks anyway)
- supermatt 2y agoThe obvious way is to use separate configs for each target - most bundlers support running these builds in parallel. It seems like you are trying to do something in a specific way instead of using the available tooling correctly. That’s not a problem with the tool. You just need to RTFM As for the “massive vtable problem”, that’s not even a tooling issue. Why are you even using JavaScript if that’s a problem for you.