egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.94k stars 217 forks source link

How can I see changes locally while build a library using tsup? #878

Open abhinav-anshul opened 1 year ago

abhinav-anshul commented 1 year ago

Hi,

I'm building a small React library using typescript + react + tsup entry point being src/index.tsx & compiling/bundling it to dist/index.js

How should I ideally see my library in localhost? Is there a way to do so using Tsup? If I'm not wrong, I can simply install live-server and create one index.html file with dist/index.js as my script file. Is this ideal?

If yes, then while publishing the library to npm do i need to manually remove live-server and index.html file everytime?

If anyone can help me out on this one, please!

Thanks

Upvote & Fund

Fund with Polar

koshic commented 1 year ago

It's a common issue when you decide to use wrapper instead of original tool. Esbuild supports dev server + watch mode out of the box - https://esbuild.github.io/api/#live-reload. But tsup doesn't. Do you really need this wrapper in your small/simple library?

For tsup, you can use something like https://tsup.egoist.dev/#onsuccess + live-server.

kealjones-wk commented 1 year ago

I am building a not-so-small library and tsup has been a great time saver for many aspect of the bundling process... but i also have this gripe with it. See: https://github.com/egoist/tsup/issues/842

I wish that we could somehow get the same feature or at least get a feature that would allow us to pull out closest equivalent of a raw esbuild config that i could then pass into esbuild directly...

abhinav-anshul commented 1 year ago

What are you building brother?

Also, I managed to get it together using live-server, someone suggested me to tweak onSuccess callback to run it on live server.

But yeah #842 would be a game changer!