-
Notifications
You must be signed in to change notification settings - Fork 413
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
fix(webpack): add cacheProvider to support customized cache #884
Conversation
Hi @malash! By pulling back filesystem-based cache we are pulling back all the problems with detecting the project root and the cache directory. I'm thinking… maybe we can just introduce a |
@Anber Good idea. I think the interface should be async. Because async interface ICache {
get: (key: string) => Promise<string>;
set: (key: string, value: string) => Promise<void>
}. If ok, I can refactor the PR. |
@Anber I realized there might be another problem if we chose the In my case I want to use Linaria with How about implementing the cache: 'memory' | 'filesystem' | ICache; It should be scalable enough ( even someone want to use Redis-based distributed build ). |
It still requires |
@Anber I refactored the PR, could you please take a look? I tested this branch in my project and it works. |
@malash thank you for your awesome work! |
I'll publish it as 2.3 later today. |
Released |
Motivation
This PR try to fix #881 . This PR is mainly inspired from a281440
Summary
This PR add a new option
cacheProvider
for Linaria loader.cacheProvider: undefined | string | ICache
(default:undefined
):By default Linaria use a memory cache to store temporary CSS files. But if you are using this loader with thread-loader you should use some consistent cache to prevent some unexpected issues. This options support a
ICache
instance or a path to NodeJS module which export aICache
instance asmodule.exports
Test plan
I run
yarn build
in this repo and copiedlibs
folder to my Linaria project'snode_modules/linaria
folder.