Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three caching questions #1100

Closed
arxpoetica opened this issue Nov 4, 2016 · 4 comments
Closed

Three caching questions #1100

arxpoetica opened this issue Nov 4, 2016 · 4 comments

Comments

@arxpoetica
Copy link

arxpoetica commented Nov 4, 2016

The JS API allows for caching: https://github.com/rollup/rollup/wiki/JavaScript-API#cache

The documentation on this is pretty sparse.

First, it's not clear, for example, how this caching would be useful from an API, since a JS file with caching might need to be watched and/or restarted with something like nodemon, hence, rendering caching useless since the app restarts and reloads everything anyway. Or is it somehow cached offline? Am I making sense?

Next up, is the cache option also available in a regular (non API) rollup.config.js file? If I, for example, throw it in a config file, then run rollup -c --watch will it do the caching magic? Or is this an API-only thing?

Finally, what exactly is getting cached?

image

@Rich-Harris
Copy link
Contributor

The idea is that the bundle can be serialized to JSON, so in theory you could save it to disk and pass it in at startup. To be honest I'm not sure off the top of my head if that actually works... The primary use case is incremental builds once Rollup has already started.

If you're using rollup.config.js, you don't need to specify anything as an option if you're using the CLI – it Just Works*. The CLI stores the bundle for you and passes it back in on the next rebuild.

Finally, what exactly is getting cached?

The implementation details are subject to change, but basically it caches the source (for comparison), the result of any transformations, and the parsed AST.

@arxpoetica
Copy link
Author

That's awesome. 👍

@weepy
Copy link

weepy commented Jul 16, 2020

@Rich-Harris it is possible to get it to do this onstart up - i.e. store the cache on disk so that startup is faster ?

@lukastaegert
Copy link
Member

The commonjs plugin will not work in such a setup at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants