-
-
Notifications
You must be signed in to change notification settings - Fork 928
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
Lazy load autoprefixer
module
#5019
Conversation
const possiblePrefixableValues = | ||
(prefixes.remove[prop.toLowerCase()] && prefixes.remove[prop.toLowerCase()].values) || false; | ||
const remove = prefixes().remove[prop.toLowerCase()]; | ||
const possiblePrefixableValues = (remove && remove.values) || false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] Fixed duplication of prefixes.remove[prop.toLowerCase()]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to get an effective benchmark for this change. Could you lease help if you have any good ideas?
I don't know either, I'm afraid.
Code looks good, though.
|
@hudochenkov Thanks for your comment. Surely, I also think we should avoid the hack on this PR if possible (to make the code simple). But, when I examine whether lazy-loading
--- a/lib/utils/isAutoprefixable.js
+++ b/lib/utils/isAutoprefixable.js
@@ -1,6 +1,7 @@
'use strict';
const autoprefixer = require('autoprefixer');
+console.log("autoprefixer loaded!!!")
const Browsers = require('autoprefixer/lib/browsers');
const Prefixes = require('autoprefixer/lib/prefixes');
/* a.css */
@-webkit-keyframes { 0% { top: 0; } } {
"rules": {
"at-rule-no-vendor-prefix": null
}
}
$ bin/stylelint.js a.css --no-cache
autoprefixer loaded!!!
{
"rules": {
}
}
$ bin/stylelint.js a.css --no-cache Perhaps, may this be another kind of bug? |
Do you think we can find why it is loaded, when it shouldn't and try to fix that? |
I'm not sure the following patch is correct, but it can prevent loading a rule module that has --- a/lib/normalizeAllRuleSettings.js
+++ b/lib/normalizeAllRuleSettings.js
@@ -20,6 +20,10 @@ function normalizeAllRuleSettings(config) {
Object.keys(config.rules).forEach((ruleName) => {
const rawRuleSettings = _.get(config, ['rules', ruleName]);
+ if (rawRuleSettings === null) {
+ return;
+ }
+
const rule = rules[ruleName] || _.get(config, ['pluginFunctions', ruleName]);
if (!rule) { stylelint/lib/normalizeAllRuleSettings.js Line 21 in 5a84657
|
This change is based on my patch on #4971 (comment).
This mainly lazy-loads the
autoprefixer
module inlib/utils/isAutoprefixable.js
.Maybe fix #4971
I don't know how to get an effective benchmark for this change. Could you lease help if you have any good ideas?