Hacker News new | past | comments | ask | show | jobs | submit login

While the article is technically correct it avoids the most common issue with 'pure' typescript libraries in that you still need a bundler if you have multiple .ts files. Once you enter that territory you realize how much more complex everything becomes.



You don't necessarily need a bundler. You could use index.ts files to re-export all the exports of your source files.


I don't see how that changes the problem that OP describes.

TS module resolution looks almost like ESM, but neither the syntax nor the semantics are the same.

And or course you need a compiler to transpile TS, even if you wish to ignore the typings (often wrapped in a bundler like Vite which in turn wraps swc or ESBuild... because tsc is not as practical for large projects)

Really, having dealt with this kind of problem on Friday, it can make you go crazy.

E.g. having to deal with CJS-specific settings for some tool in a project using TS and exporting to ESM JS...


You don't need a bundler with multiple .ts files any more than with multiple .js file - which is that you don't "need" one at all.

Libraries especially don't and should be published to npm unbundled. Bundling is purely an application concern.


So consumers are forced to use a bundler/ts just because some random dependency decided they're too lazy to deal with a bundler?

> Bundling is purely an application concern

by this logic all compiled languages' repos should just be source, no precompiled binaries.


yes. Always include source and let the user/client decide. Include a bundled version is OK, but it should be only there for convenience.


so explain to me again why I have to change my entire toolchain for simply consuming a library? What if I consume a wasm library written in Rust, suddenly I have to add rust into my build script? What is the point of bytecode if people are going to repeat the same build over and over again anyway?


it's unfortunate that javascript (and typescript) is not bytecode.


It's the same in that js is the standard runtime, and typescript is something that compiles to it, that's NOT used in all codebases




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: