-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
feat: add options validation #224
feat: add options validation #224
Conversation
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.
Can you split this into two PRs? Restructuring and schema. Now it's a little tricky to review. :)
@bebraw Yeah sry 😛 it come over me, could we make an exception this time please? 🙃 🙏 |
It's just |
no logic related changes and the tests pass.. :) |
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.
Seems very good, some note
lib/addStyles.js
Outdated
|
||
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style> | ||
// tags it will allow on a page | ||
if (typeof options.singleton === "undefined") options.singleton = isOldIE(); |
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.
Why typeof
?
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.
¯_(ツ)_/¯ Good catch, will update :)
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.
done
lib/addStyles.js
Outdated
if(domStyle) { | ||
domStyle.refs++; | ||
|
||
for(var j = 0; j < domStyle.parts.length; j++) { |
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.
Seems it can do in one loop
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.
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 wll take a look into that
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.
for(var j = 0; j < domStyle.parts.length && item.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
domStyle.parts.push(addStyle(item.parts[j], options));
}
@evilebottnawi &&
or ||
? 🙃 the tests pass with &&
, but I'm not 💯 on this :D
package.json
Outdated
"description": "style loader module for webpack", | ||
"engines": { | ||
"node": ">= 0.12.0" |
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.
Why? 😄 maybe 4 minimum?
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.
Yep but this PR is minor and current style-loader
is node =< 4 aswell, I bump it with the webpack-defaults
upgrade 😛
"node": ">= 0.12.0" | ||
}, | ||
"main": "index.js", | ||
"files": [ |
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.
We have not forgotten anything? Maybe be good add to default smoke
test?
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 this a rhetoric question just to double check or did I miss something obvious ? 🙃
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.
We have && done 😛
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.
Seems good, I hope we did not break anything 😛
@evilebottnawi blocked by webpack/schema-utils#9 it's an enterily stupid issue, but any ideas welcome 😛 |
My apologizes for the PR size again 🙏 , wouldn't happen again 😛 |
module.exports = function () {}; | ||
|
||
module.exports.pitch = function (request) { | ||
if (this.cacheable) this.cacheable(); |
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.
this.cacheable
shouldn't be needed in webpack 2 anymore if I understood right.
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 left it because it's semver minor & planned to remove with webpack-defaults
upgrade in the upcoming major, but we can remove it if consensus is found about it
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.
Ok, that's fine.
module.exports.pitch = function (request) { | ||
if (this.cacheable) this.cacheable(); | ||
|
||
var options = loaderUtils.getOptions(this) || {}; |
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.
Maybe getOptions
should return {}
by default? Worth checking.
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.
You mean var options = loaderUtils.getOptions(this)
returns {}
anyways ? mom I will check that :)
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.
Check for sure. If it doesn't, figure out why it doesn't return an {}
. That would seem like a sensible default or else we end up with the check everywhere.
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.
use: [ 'style-loader' ] // options === null
getOptions
returns null
😕
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.
Ok, maybe escalate to loader-utils. It would make sense to change the default from consumer point of view. I wonder what's the reasoning for null
. It's easier if you get an object always.
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.
Yep {}
would be better, I open an issue at loader-utils
is this blocking the PR ?
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.
Not blocking. The current implementation is fine.
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.
}, | ||
"convertToAbsoluteUrls": { | ||
"type": "boolean" | ||
} |
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.
It would be a good idea to add a description field for each.
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.
For some reason it doesn't get displayed in the OptionsValidationError
@schema-utils, but agreed this is mandatory to some point, but I need to fix it in schema-utils
first 😛
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.
Sure.
I took a note about #224 (comment) in case it should cause an unforeseen regression and needs to be reverted, works fine locally so far and test pass, but... 😛 |
#What kind of change does this PR introduce?
Did you add tests for your changes?
😛 Yep
If relevant, did you update the README?
👌 #222
Summary
Fixes #223
css-loader
,file-loader
,jsdom
)Does this PR introduce a breaking change?
Nope