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
Added cache object to node-sass-once-importer #166
Added cache object to node-sass-once-importer #166
Conversation
Hey @konpikwastaken thanks for your pull request! I highly appreciate it! I'll add a few comments for some very minor (style) improvements. Big Thanks for contributing! |
Also, some tests are failing, please take a look at it :) You can run the tests locally with Thx. |
I'll take a look at it! |
Looks like tests pass now. After further review of the code - I removed one of the checks. The larger pull seems to be in |
Hey @konpikwastaken I was already in the process of making some final touches and merging the branch into master, when I realized, that this is not the correct way of doing it. The return of const url = 'foo.scss';
const includePathsA = ['/path/foo', '/path/bar'];
const a = resolveUrl(url, includePathsA);
const includePathsB = ['/path/baz'];
const b = resolveUrl(url, includePathsB);
console.log(a === b); // false You have to do something like that: // Generates something like `/foo.scss|/path/foo|/path/baz`.
const cacheKey = [url, ...includePaths].join('|');
if (!cache.has(cacheKey)) {
cache.set(cacheKey, resolveUrl(
url,
includePaths,
));
}
resolvedUrl = cache.get(cacheKey); Because the I've tested the performance improvements with Bootstrap, and they were basically non existent. Feel free to make your own tests tough. I'm happy to accept a pull request which uses the Or maybe there is some other way of how to avoid Thx. |
Hm, yes, I see what you're saying. I wonder if the improvement observed in our code base is due to the way that our imports are structured. I'll take another look once I get a chance. As for the glob call, I'll think more on it :). Cheers, sorry for the churn! |
We have a very long build step, lots of files being written with a legacy & new code base.
This change speeds up file resolution for us by up to 15s on a baseline 75-80s build step.