feat: add options validation#224
feat: add options validation#224michael-ciniawsky merged 1 commit intowebpack:masterfrom michael-ciniawsky:schema
Conversation
bebraw
left a comment
There was a problem hiding this comment.
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.. :) |
alexander-akait
left a comment
There was a problem hiding this comment.
Seems very good, some note
|
|
||
| // 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.
¯_(ツ)_/¯ Good catch, will update :)
| if(domStyle) { | ||
| domStyle.refs++; | ||
|
|
||
| for(var j = 0; j < domStyle.parts.length; j++) { |
There was a problem hiding this comment.
Seems it can do in one loop
There was a problem hiding this comment.
There was a problem hiding this comment.
👍 I wll take a look into that
There was a problem hiding this comment.
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
| "author": "Tobias Koppers @sokra", | ||
| "description": "style loader module for webpack", | ||
| "engines": { | ||
| "node": ">= 0.12.0" |
There was a problem hiding this comment.
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.
We have not forgotten anything? Maybe be good add to default smoke test?
There was a problem hiding this comment.
I this a rhetoric question just to double check or did I miss something obvious ? 🙃
There was a problem hiding this comment.
We have && done 😛
alexander-akait
left a comment
There was a problem hiding this comment.
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.
this.cacheable shouldn't be needed in webpack 2 anymore if I understood right.
There was a problem hiding this comment.
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
| module.exports.pitch = function (request) { | ||
| if (this.cacheable) this.cacheable(); | ||
|
|
||
| var options = loaderUtils.getOptions(this) || {}; |
There was a problem hiding this comment.
Maybe getOptions should return {} by default? Worth checking.
There was a problem hiding this comment.
You mean var options = loaderUtils.getOptions(this) returns {} anyways ? mom I will check that :)
There was a problem hiding this comment.
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.
use: [ 'style-loader' ] // options === null
getOptions returns null 😕
There was a problem hiding this comment.
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.
Yep {} would be better, I open an issue at loader-utils is this blocking the PR ?
There was a problem hiding this comment.
Not blocking. The current implementation is fine.
There was a problem hiding this comment.
| }, | ||
| "convertToAbsoluteUrls": { | ||
| "type": "boolean" | ||
| } |
There was a problem hiding this comment.
It would be a good idea to add a description field for each.
There was a problem hiding this comment.
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 😛
|
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