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

Fix: Correctly load v8-compile-cache #6261

Merged
merged 1 commit into from
Aug 12, 2018
Merged

Fix: Correctly load v8-compile-cache #6261

merged 1 commit into from
Aug 12, 2018

Conversation

zertosh
Copy link
Member

@zertosh zertosh commented Aug 11, 2018

v8-compile-cache is not loading because fs.existsSync is checking for a file that doesn't exist. fs.existsSync resolves relative to the cwd, not the current module (like require), and v8CompileCachePath's filename is missing .js.

Instead of checking for the existence of v8-compile-cache.js, just try to require it in a try/catch, using a full path. Also switched the require of cli.js to use the same pattern for consistency (plus it's a module resolution micro-optimization).

# before
$ time ./dist/bin/yarn -v
1.10.0-0
./dist/bin/yarn -v  0.28s user 0.06s system 98% cpu 0.344 total

# after
$ time ./dist/bin/yarn -v
1.10.0-0
./dist/bin/yarn -v  0.16s user 0.05s system 97% cpu 0.213 total

Copy link
Member

@Daniel15 Daniel15 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 to me. Thanks!

@Daniel15 Daniel15 merged commit 77b8444 into yarnpkg:master Aug 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants