-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(core): reduce time it takes to require nx commands #28884
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit fd48dd6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targets
Sent with 💌 from NxCloud. |
|
||
export const yargsInitCommand: CommandModule = { | ||
command: 'init', | ||
describe: | ||
'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.', | ||
builder: (yargs) => withInitOptions(yargs), | ||
builder: async (yargs) => (await import('./init')).withInitOptions(yargs), |
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 change shouldn't make much functional difference, and I'd prefer to keep builder inside command-object. The builders have to run for every command anyway and the idea of the dynamic require on the handler is to avoid pulling in things required for implementation on every command. Having this here defeats that purpose.
If you wanted to pull builder logic / withInitOptions into a separate file, it'd need to be a different file than the implementation logic, and I don't think its worth it. It's not like the yargs stuff is pulling in more than any other command.
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
nx/src/command-line/nx-commands
takes ~88-91ms on my machine to require which needs to happen for every single Nx command.Expected Behavior
nx/src/command-line/nx-commands
takes ~30-33ms on my machine to require.Related Issue(s)
Fixes #