Skip to content

Defer CJS imports in CLI#352

Merged
frandiox merged 2 commits intov0.x-2022-10from
fd-cli-defer-cjs-imports
Jan 5, 2023
Merged

Defer CJS imports in CLI#352
frandiox merged 2 commits intov0.x-2022-10from
fd-cli-defer-cjs-imports

Conversation

@frandiox
Copy link
Copy Markdown
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.

@frandiox frandiox requested review from cartogram and pepicrft January 5, 2023 12:49
import {createRequire} from 'module';
import path from 'path';
import fs from 'fs-extra';
import fs from 'fs/promises';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice

Copy link
Copy Markdown
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
Copy Markdown
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