Skip to content
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

Merged
merged 11 commits into from
Apr 14, 2017

Conversation

loganfsmyth
Copy link
Member

Q A
Patch: Bug Fix? N
Major: Breaking Change? N
Minor: New Feature? N
Deprecations?
Spec Compliancy?
Tests Added/Pass?
Fixed Tickets
License MIT
Doc PR
Dependency Changes

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?

@loganfsmyth loganfsmyth added this to the Babel 7 milestone Apr 7, 2017
@loganfsmyth loganfsmyth requested a review from hzoo April 7, 2017 05:42
@mention-bot
Copy link

@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.

Copy link
Member

@xtuc xtuc left a 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) {
Copy link
Member

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'),
  ]
}

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more createInitialOptions?

Copy link
Member Author

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
Copy link

codecov bot commented Apr 7, 2017

Codecov Report

Merging #5602 into 7.0 will increase coverage by 0.03%.
The diff coverage is 75.86%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/babel-messages/src/index.js 61.53% <ø> (ø) ⬆️
...bel-core/src/config/loading/files/index-browser.js 0% <0%> (ø) ⬆️
packages/babel-core/src/config/index.js 100% <100%> (ø) ⬆️
packages/babel-core/src/config/plugin.js 100% <100%> (+25%) ⬆️
...ges/babel-core/src/config/loading/files/plugins.js 47.82% <50%> (ø) ⬆️
packages/babel-core/src/config/option-manager.js 77.77% <77.5%> (+0.97%) ⬆️
packages/babel-traverse/src/path/context.js 86.2% <0%> (ø) ⬆️
packages/babel-traverse/src/visitors.js 86.66% <0%> (+0.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ea3338...248c240. Read the comment docs.

@xtuc xtuc added i: enhancement PR: Internal 🏠 A type of pull request used for our changelog categories labels Apr 7, 2017
@@ -146,7 +146,7 @@ describe("api", function () {
plugins: [__dirname + "/../../babel-plugin-syntax-jsx", false],
});
},
/TypeError: \[BABEL\] unknown: Falsy value found in plugins/
Copy link
Member

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"?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

@hzoo hzoo left a 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)

@loganfsmyth loganfsmyth merged commit ad250ef into babel:7.0 Apr 14, 2017
@loganfsmyth loganfsmyth deleted the option-manager-cleanup branch April 14, 2017 21:25
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants