I'm working on a number of NPM packages in TypeScript and I'm wondering about the best way to support different target architectures.
If you compile to ES3, you have the widest support, but also additional boilerplate for compatibility (size, partially impossible to parse). If you target esnext, you basically have no boilerplate (clean output code!), but very limited support.
The problem is that the TypeScript compiler does not transpile JS code or any code from node_modules
in general. Hence, if you e.g. compile a library to ES6 and someone wants to use it in their browser app (targeting ES3 or ES5), then they wouldn't be able to just use that library.
What is the best practice here? How should I configure my package.json
and tsconfig.json
? And if the library user will need to do something, what's the preferred way here?
Thanks a lot!