-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
perf: use fsp in more cases #12553
perf: use fsp in more cases #12553
Conversation
Run & review this pull request in StackBlitz Codeflow. |
packages/vite/src/node/http.ts
Outdated
cert: readFileIfExists(cert), | ||
key: readFileIfExists(key), | ||
pfx: readFileIfExists(pfx), | ||
ca: await readFileIfExists(ca), |
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.
Promise.all ??
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.
Good idea, done at vitejs/vite@de5e611
(#12553). Also simplified the logic.
@@ -1099,7 +1100,7 @@ async function loadConfigFromBundledFile( | |||
// for cjs, we can register a custom loader via `_require.extensions` | |||
else { | |||
const extension = path.extname(fileName) | |||
const realFileName = fs.realpathSync(fileName) | |||
const realFileName = await fsp.realpath(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.
Note: The fsp version of realpath
uses .native
by default, which would cause file read errors on Windows for network drives. But since we're not doing that here, this change should be safe.
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 caused #12923, the async version returns a path with uppercase volume letter C:\...
whereas the earlier version returns it lowercase, so the equality check on line 1107 no longer works.
Description
Use fs/promises to avoid blocking the main thread in more cases. While we are scanning or pre-bundling, we are also processing for example.
What is the purpose of this pull request?