Skip to content

Commit b7026ad

Browse files
authored
perf: lazily import resolveConfig (#190)
### TL;DR Dynamically import `resolveConfig` in the `resolveUniversalViteConfig` function instead of importing it at the top level. `resolveConfig` imports `rolldown-vite` which takes nearly 100ms. It's not actually used if cache is hit. Lazily importing it improves the startup time. ### Before: ![image.png](https://app.graphite.dev/user-attachments/assets/fe0bd5bf-0cee-43cd-bae3-936d0dcf4c00.png) ### After: ![image.png](https://app.graphite.dev/user-attachments/assets/84bb820e-d2c7-4f30-9fd2-fc55bf5bf141.png)
1 parent 04c05d7 commit b7026ad

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

packages/cli/src/bin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import { run } from '../binding/index.js';
1313
import { doc } from './doc.js';
1414
import { fmt } from './fmt.js';
15-
import { resolveConfig } from './index.js';
1615
import { lib } from './lib.js';
1716
import { lint } from './lint.js';
1817
import { test } from './test.js';
@@ -22,7 +21,7 @@ async function resolveUniversalViteConfig(err: null | Error, viteConfigCwd: stri
2221
if (err) {
2322
throw err;
2423
}
25-
24+
const { resolveConfig } = await import('./index.js');
2625
const config = await resolveConfig({ root: viteConfigCwd }, 'build');
2726

2827
return Promise.resolve(JSON.stringify({

0 commit comments

Comments
 (0)