rollup / stream

🍣 Stream Rollup build results
MIT License
22 stars 12 forks source link

Cache support for better performance #1

Closed Dan503 closed 4 years ago

Dan503 commented 4 years ago

Feature Use Case

You are running Gulp watch so it runs rollup every time you save. You make a small change to one of the files and save. Instead of waiting for Rollup to recalculate the entire package bundle from scratch, it can improve performance by using data from the last bundle to only recalculate what is different.

Feature Proposal

The old rollup-stream plugin supported a cache option that allowed bundling performance to be drastically faster by only recalculating what had changed.

You can see an example of how the cache option was used in this example: https://github.com/Dan503/gulp-file-loader/blob/master/README.md#rollup-in-gulp-4

If it was capable of self-caching without any extra code, that would be even better.

If this has already been implemented then documenting it would be helpful.

If not, this is an important feature that most Gulp users would benefit greatly from.

shellscape commented 4 years ago

This is actually baked into Rollup. See: https://www.rollupjs.org/guide/en/#cache

The old rollup-stream wasn't actually doing anything with caching. See: https://github.com/Permutatrix/rollup-stream/blob/master/index.js

So you should already have this ability.

Dan503 commented 4 years ago

Oh ok. I'm going to look into this tomorrow.

It would be good if this was clearly documented as part of the readme. This is incredibly important for fast build times.

shellscape commented 4 years ago

I'm not convinced that we need a readme section on this module. It's already stated clearly that all rollup options can be used, and are linked. Caching is pretty well documented on Rollup's site, and this module isn't limited to Gulp. Gulp is a popular streaming application, but definitely not the only one.

Dan503 commented 4 years ago

The key thing that is confusing for Gulp users that is specific to this plugin is this question:

"How do I update the cached Rollup bundle using Gulp?"

This is something specific to @rollup/stream and if it isn't answered in the readme then the only way I can see for people to be able to answer that question is to look into the source code which is terrible UX.

This is something that seems silly to obscure from the user when 99% of Gulp users will need to make use of the cache option to optimise their watch task.

I'm working on a pull request right now to add documentation to the readme on how to optimise the Rollup gulp watch task.

Dan503 commented 4 years ago

Pull request created: https://github.com/rollup/stream/pull/3

shellscape commented 4 years ago

Closed by #3.

Dmitri-Sintsov commented 3 years ago

Is there any way to detect that the next run of bundle.cache was changed comparing to previous one? I need to store the output of bundle, not the cache itself. I pass the previous cache to next run of rollup options and it looks like cache is used indeed, resulting in much faster builds. But still I do not know actually was there a single change or anything was not altered?