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

Defer CJS imports in CLI #352

Merged
merged 2 commits into from
Jan 5, 2023
Merged

Defer CJS imports in CLI #352

merged 2 commits into from
Jan 5, 2023

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Jan 5, 2023

There's an ongoing effort to improve CLI start up times. This PR delays CJS imports (remix, fs-extra, and mini-oxygen), which apparently are the slowest.

From @pepicrft

We continued the investigation today and found out that the bottleneck is caused by 3P dependencies that are CommonJS. If you have any of those, I recommend loading them dynamically.
The ones that are ESM is find because NodeJS parallelizes the loading so the total time is roughly the time of the slowest of them.

import {createRequire} from 'module';
import path from 'path';
import fs from 'fs-extra';
import fs from 'fs/promises';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@frandiox frandiox merged commit d979fed into v0.x-2022-10 Jan 5, 2023
@frandiox frandiox deleted the fd-cli-defer-cjs-imports branch January 5, 2023 18:27
@cartogram
Copy link
Contributor

🥇

@github-actions github-actions bot mentioned this pull request Feb 8, 2023
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.

4 participants