-
-
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
chore: Speed up lint-staged
#14896
chore: Speed up lint-staged
#14896
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52853/ |
bb4999e
to
0e48367
Compare
Also I found that an overly complex |
yarn lint-staged | ||
# Specifying `config` manually avoids `lint-staged` scanning the entire repository, even `package.json` containing test suites. | ||
# Use `--no-stash` to skip backup files as we don't automatically fix lint errors. | ||
./node_modules/.bin/lint-staged --config package.json --no-stash |
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.
./node_modules/.bin/lint-staged --config package.json --no-stash | |
yarn lint-staged --config package.json --no-stash |
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.
PS F:\babel> Measure-Command {yarn lint-staged}
Days : 0
Hours : 0
Minutes : 0
Seconds : 2
Milliseconds : 773
Ticks : 27731558
TotalDays : 3.20967106481481E-05
TotalHours : 0.000770321055555556
TotalMinutes : 0.0462192633333333
TotalSeconds : 2.7731558
TotalMilliseconds : 2773.1558
PS F:\babel> Measure-Command {./node_modules/.bin/lint-staged}
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 454
Ticks : 4540090
TotalDays : 5.2547337962963E-06
TotalHours : 0.000126113611111111
TotalMinutes : 0.00756681666666667
TotalSeconds : 0.454009
TotalMilliseconds : 454.009
yarn
adds an extra 2s, which I tend to avoid.
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.
Oh ok. I'm surprised that it's this slow just to load a script.
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, this seems to be brought by yarn3, which creates a new virtual environment for all commands.
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.
FYI here is my benchmark results
time yarn lint-staged
→ No staged files found.
yarn lint-staged 0.62s user 0.10s system 114% cpu 0.634 total
time ./node_modules/.bin/lint-staged
→ No staged files found.
./node_modules/.bin/lint-staged 0.17s user 0.04s system 70% cpu 0.285 total
I am good either way if the startup time is less than 1 sec, but the Windows platform performance is a bit annoying. Maybe yarn PnP will save us some time here? /cc @merceyz
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.
Merge it 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.
@JLHwung If the startup time in this case is just Yarn it probably wont help, we are aware of the issue though.
Ref yarnpkg/berry#2575
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
babel.config.js
Outdated
@@ -304,13 +304,30 @@ module.exports = function (api) { | |||
config.plugins.push("babel-plugin-istanbul"); | |||
} | |||
|
|||
if (api.caller(caller => caller && caller.name == "@babel/eslint-parser")) { | |||
// We disable all the plugins and presets, since we are only interested in parsing JS. |
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.
Instead of caller detection in Babel config, can we disable the whole Babel config loading in
sourceType: "module", |
See also https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser#additional-parser-configuration
Even without any caching, submitting a JS file was able to drop from 8.3 seconds to 2.6 seconds.