marked icon indicating copy to clipboard operation
marked copied to clipboard

Move from `terser` to `esbuild`

Open baseplate-admin opened this issue 1 year ago • 7 comments

What pain point are you perceiving?. it seems that marked is using terser for bundling

https://github.com/markedjs/marked/blob/de85e706e6dd3b3c4b2f836abc7ad8f206640045/rollup.config.js#L2

https://github.com/markedjs/marked/blob/de85e706e6dd3b3c4b2f836abc7ad8f206640045/rollup.config.js#L44

But terser is slower ( about 10x ) than esbuild.

Describe the solution you'd like It would be better if marked moved to esbuild + rollup ( or maybe vite ) for it's bundling process.

Rollup has : rollup-plugin-esbuild

Vite natively supports esbuild

baseplate-admin avatar Sep 15 '23 05:09 baseplate-admin

I don't feel like our build times are a problem. They are only a couple seconds currently. I went with terser because the plugin is developed by rollup and more likely to continue being supported than a plugin created by a lone developer.

I'm ok with either. It should be easy to switch in the future if needed.

UziTech avatar Sep 15 '23 15:09 UziTech

I don't feel like our build times are a problem. They are only a couple seconds currently.

True, but esbuild gets more attention than terser because vite (and a lot of major frameworks) are using esbuild.

I went with terser because the plugin is developed by rollup and more likely to continue being supported than a plugin created by a lone developer.

Then why not switch to vite in library mode?

baseplate-admin avatar Sep 16 '23 02:09 baseplate-admin

I've never used vite, but I'm all for learning new things. Are you talking about replacing our docs with vite?

UziTech avatar Sep 16 '23 05:09 UziTech

I've never used vite, but I'm all for learning new things

That's something i rarely see. Most of the people are impervious to change.

Are you talking about replacing our docs with vite?

I was talking about replacing rollup with vite


If you want i can try to send a PR, replacing rollup with vite

baseplate-admin avatar Sep 16 '23 05:09 baseplate-admin

Sure, it looks like vite uses rollup anyways so I don't see the point in adding a new layer. But if you create a PR we can see what the benefits are.

UziTech avatar Sep 16 '23 14:09 UziTech

If it can reduces the size of the npm package I think it would be worth it. The gzip size grew dramatically after switching to typescript. Mainly because we now have to include source maps for each file.

UziTech avatar Sep 16 '23 17:09 UziTech

@UziTech If you're interested in migrating to Vite, I've reproduced the source code for Marked (without making any edits), and it works like a charm! Feel free to check out this repository.

bent10 avatar Oct 05 '23 13:10 bent10