-
-
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
Misc reorganizing and prep for ignore/only refactoring #5467
Conversation
@loganfsmyth, thanks for your PR! By analyzing the history of the files in this pull request, we identified @existentialism, @jamestalmage and @hzoo to be potential reviewers. |
Codecov Report
@@ Coverage Diff @@
## 7.0 #5467 +/- ##
=========================================
+ Coverage 85.31% 85.5% +0.19%
=========================================
Files 202 201 -1
Lines 9526 9510 -16
Branches 2702 2695 -7
=========================================
+ Hits 8127 8132 +5
+ Misses 907 887 -20
+ Partials 492 491 -1
Continue to review full report at Codecov.
|
if (opts.babelrc !== false) { | ||
builder.findConfigs(filename); | ||
} | ||
|
||
builder.mergeConfig({ |
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.
By swapping the order of these, we'll be able to bail out based on ignore
and only
match failure, before having to search for the .babelrc
which will be a big performance win.
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.
That's really good 🚀
} | ||
|
||
opts.filename = filename; | ||
opts = new OptionManager().init(opts); |
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.
Pulled out OptionManager#init
calls into these so that we won't have to bother reading the file content from disk if the filename fails the ignore/only check.
@@ -111,20 +126,22 @@ export function booleanify(val: any): boolean | any { | |||
|
|||
export function shouldIgnore( |
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.
The changes to this function make it required that you both match only
and don't match ignore
. With the old logic of only using only
when present meant that we needed to aggregate the whole config tree before processing only
and ignore
. Like say you had
babel.transform(..., {ignore: "**/*.jsx"});
but your .babelrc
was
{
only: ['**/*.jsx'],
}
in v6 the logic would compile all .jsx
files because it would pass only
, and we're required to read the .babelrc
of every file even if they won't match the ignore
pattern passed to .transform
.
@@ -84,16 +84,6 @@ describe("buildConfigChain", function () { | |||
const expected = [ | |||
{ | |||
options: { |
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 diff isn't great, but what moved here was the .babelignore
ordering. But since we just append ignore
values together, this change in ordering should essentially be a noop.
const fileName = state.file.log.filename !== "unknown" | ||
? state.file.log.filename | ||
: null; | ||
const fileName = state.file.opts.filename; |
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 sure why this code was written this way anyway.
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.
phew did it. I think we should think about some more tests thou
Fixes #1, Fixes #2
Alongside the refactoring, this removes
opts.basename
used by some plugins in favor of usingopts.filename
directly and generating the basename in the few plugins it was used by.EDIT:
Oh and a second breaking change. Previously if you specified
only
thenignore
would never be processed. So the logic wasmeaning that
only: ['foo.js'], ignore: ['.js']
would compile a file namedfoo.js
even though it is being ignored.Now it is