Only load cssnano if we're going to use it. #472
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
bugfix
Did you add tests for your changes?
N/A
If relevant, did you update the README?
N/A
Summary
css-loader relies on cssnano, which relies on postcss-filter-plugins, which relies on uniqid, which relies on macaddress.
macaddress has a global leak in v0.2.8. They accidentally create a global variable named
addresses
. This is a problem, because if you use this pacakge, and you supply--check-leaks
to mocha, mocha will spaz out about the fact that there's this extra global variable.The good news is, this is fixed in macaddress#master. The bad news is, they haven't published the fix for 9 months.
uniqid relies on macaddress (and, obnoxiously, calls it at top-level-scope), so I'd like to harass them into switching from macaddress to some other package, but they were made aware of this issue six months ago, and they still haven't done anything.
I've raised an issue with postcss-filter-plugins, but they had a PR that would have fixed this and the closed it without merging it because they're going to deprecate postcss-filter-plugins and remove it from cssnano entirely.
So, this is a slightly awful fix which makes it so we don't even
require
cssnano in css-loader unless we plan to do some minimization. Since that's the default, it should fix this problem for most people. Note that node will cache the required cssnano, so if you are using minimization, this won't cause any noticeable performance problems (and I suppose it will very marginally speed things up for people who aren't doing minimization).Does this PR introduce a breaking change?
No.