You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I have a quite complex setup for PostCSS loader and I want to use happypack, so I'm forced to use a postcss.config.js file to configure postcss-loader.
I have a single postcss.config.js file in my project with a stable content. I use options to configure it at the first time, but then it remains the same all the time. But I found out that postcss-loader doesn't cache my config file and recreates all the configuration for every single file in the project. This slows down my build time for about 10 seconds.
cosmiconfig caches the file by default to avoid repetitive fs calls. The config needs to be evaluated for each file, bc of the context when using a {Function}. Do you have a concrete solution for one of our proposed solutions in mind ? Does your build time decline when using a fixed path to the config file ?
What do you mean by remove :) ? If there is a way to refactor with the current logic staying in place but improved caching/memoization feel free to open a PR. Otherwise I'm afraid this is won't fix
I have something in mind but this needs to be done in postcss-load-config instead with the next upgrade (memoize the config {Function}), I will leave the issue open for tracking purposes
@simonbuchan Thx I will definitely look into it :). Should be similar to memoizing the {Function} calls in postcss-load-config, but I will check what they did aswell 😛
Activity
michael-ciniawsky commentedon Oct 26, 2017
cosmiconfig caches the file by default to avoid repetitive
fscalls. The config needs to be evaluated for each file, bc of the context when using a{Function}. Do you have a concrete solution for one of our proposed solutions in mind ? Does your build time decline when using a fixed path to the config file ?s-panferov commentedon Oct 26, 2017
@michael-ciniawsky
Yes, I have a fixed path to a config file. The main problem is evaluation, not reading from a file system.
The simplest solution is to take this function from options. This would allow me to write a simple caching decorator.
michael-ciniawsky commentedon Oct 26, 2017
What do you mean by remove :) ? If there is a way to refactor with the current logic staying in place but improved caching/memoization feel free to open a PR. Otherwise I'm afraid this is won't fix
s-panferov commentedon Oct 26, 2017
@michael-ciniawsky I haven't used the word
remove:) Ok, I'll send a PR todaymichael-ciniawsky commentedon Oct 26, 2017
Then I misunderstood your intend 😛
kk
[-]Inefficient config loading[/-][+][postcss.config.js] Inefficient config loading[/+]michael-ciniawsky commentedon Oct 30, 2017
Did you find a solution ?
michael-ciniawsky commentedon Nov 28, 2017
I have something in mind but this needs to be done in
postcss-load-configinstead with the next upgrade (memoize the config{Function}), I will leave the issue open for tracking purposessimonbuchan commentedon Jan 24, 2018
Sounds like OP wants something like babel 7's caching api for
.babelrc.js. Essentially:now babel only needs to evaluate
aExprandbExprfor each file. There's a bunch more detail, but no docs yet, other than the error you get when it's not configured: https://github.com/babel/babel/pull/5608/filesmichael-ciniawsky commentedon Jan 24, 2018
@simonbuchan Thx I will definitely look into it :). Should be similar to memoizing the
{Function}calls inpostcss-load-config, but I will check what they did aswell 😛