wessberg / rollup-plugin-ts

A TypeScript Rollup plugin that bundles declarations, respects Browserslists, and enables seamless integration with transpilers such as babel and swc
MIT License
496 stars 32 forks source link

How to build for both Node.js and Browsers? #187

Open ThisIsMissEm opened 2 years ago

ThisIsMissEm commented 2 years ago

Question

Hi! I've just come across rollup-plugin-ts, and I'm liking what I'm seeing, I do have a question though, which is, how does this play with compiling a single package for both Node.js and Browsers? I currently use the rollup-plugin-typescript2 plugin, which seems to not care, but from what I can tell rollup-plugin-ts, due to supporting browserslist would maybe compile code that would work in browsers but not in node?

Would I need two different plugins? One for Node.js and one for Browsers?

Or would we just set browserslist to something like:

  "browserslist": [
     "last 2 versions",
     "maintained node versions"
   ]

And that would output code that's compatible with both Node.js and browsers?