-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[cli] add compile cache to improve startup performance #12783
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 07d680d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
"use strict"; | ||
// This shim defers loading the real module until the compile cache is enabled. | ||
// https://nodejs.org/api/module.html#moduleenablecompilecachecachedir | ||
try { |
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 try/catch is to make this a no-op on Node < 22?
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.
Correct
|
||
writeFileSync( | ||
new URL('vc.js', distRoot), | ||
`#!/usr/bin/env node |
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.
Any reason in particular why this is defined inline? How about we move it to a separate file which gets copied to dist
?
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.
I was going to do that but the code was small and unlikely to change.
We also write a file here so its not unprecedented:
vercel/packages/cli/scripts/build.mjs
Lines 8 to 14 in 6150fbe
function createConstants() { | |
const filename = new URL('src/util/constants.ts', repoRoot); | |
const contents = `// This file is auto-generated | |
export const SENTRY_DSN: string | undefined = ${envToString('SENTRY_DSN')}; | |
`; | |
writeFileSync(filename, contents, 'utf8'); | |
} |
If you feel strongly I can move it to a separate file. I'm just not sure which directory it should live in.
This improves the startup of Vercel CLI from 18ms to 13ms on my MacBook Pro M3 running Node.js 22.
References