-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Refactor OptionManager to be a short class with a bunch of pure helper functions. #5602
Conversation
@loganfsmyth, thanks for your PR! By analyzing the history of the files in this pull request, we identified @danez, @hzoo and @existentialism to be potential reviewers. |
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.
Looking good! Great work @loganfsmyth 👍
|
||
let inheritsDescriptor; | ||
let inherits; | ||
if (plugin.inherits) { |
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 had the discussion in a PR last time, could we support multiple inheritance?
{
inherits: require('foo')
}
vs
{
inherits: [
require('foo'),
require('bar'),
]
}
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.
Yeah, definitely something we could add.
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 think I'll leave it for a future PR, but it wouldn't be too bad to add if we want.
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.
Yes sure. I will note this in my todo list.
} | ||
|
||
OptionManager.memoisedPlugins = []; | ||
function createBareOptions() { |
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 is more createInitialOptions
?
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.
Yeah, I just left the name we had in there already, but I can change it too.
Codecov Report
@@ Coverage Diff @@
## 7.0 #5602 +/- ##
==========================================
+ Coverage 84.45% 84.48% +0.03%
==========================================
Files 285 285
Lines 9648 9644 -4
Branches 2711 2700 -11
==========================================
Hits 8148 8148
+ Misses 998 996 -2
+ Partials 502 500 -2
Continue to review full report at Codecov.
|
8a1d05e
to
118d861
Compare
118d861
to
248c240
Compare
@@ -146,7 +146,7 @@ describe("api", function () { | |||
plugins: [__dirname + "/../../babel-plugin-syntax-jsx", false], | |||
}); | |||
}, | |||
/TypeError: \[BABEL\] unknown: Falsy value found in plugins/ |
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.
So we are ok just saying this is "falsy"?
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 does append the value itself now, before it didn't.
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.
nvm I was talking about it saying it was a plugin/preset before but maybe that's not a big deal
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.
looks good, crazy stuff (I went through using --inspect)
Last PR before I post the changes to OptionManager for caching. This PR is basically slowly moving things around and simplifying OptionManager, so it no longer has all kinds of hard to follow statics. It's a simple class 100 lines long, with a bunch of pure functions that it uses to slowly build up the config info.
Review-wise it might be easier to just look at the final option-manager.js file to say what you think?