From 6e120f26d58ec24812f671b962ee46c99d86a682 Mon Sep 17 00:00:00 2001 From: Tom Meyer Date: Wed, 11 Oct 2023 09:22:17 -0700 Subject: [PATCH] Ignore Cached Dependencies when Starting Studio. (#405) In Vite, your project's dependencies are pre-bundled before the Dev server loads your site. As an optimization, Vite allows these bundled dependencies to be cached. If a dependency hasn't changed, Vite does not need to pre-bundle it again. See details here: https://vitejs.dev/guide/dep-pre-bundling.html#caching. Unfortunately, this caching behavior is causing significant problems in Storm (https://yext.slack.com/archives/C03F59PCJRK/p1696964495301699). In this PR, I remove the cache optimization from Studio's Vite instance. This is done by running Vite with `--force`. Although it wasn't strictly necessary, I also removed `optimizeDeps` from the Vite Config. Dependencies will always be pre-bundled whenever Studio starts up. Removing this optimization, I did not notice a big drop in performance locally. J=SLAP-2961 TEST=manual I ran this new version of Studio against the Test Site. I verified none of the cached dependencies were used and that Studio started up as expected. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- packages/studio/bin/studio.ts | 10 +++++++++- packages/studio/vite.config.ts | 3 --- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index e38730ee5..43de13867 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -18,7 +18,15 @@ cli .action((options: CliArgs) => { spawnSync( "npx", - ["cross-env", NODE_OPTIONS, "npx", "vite", "--config", pathToViteConfig], + [ + "cross-env", + NODE_OPTIONS, + "npx", + "vite", + "--force", + "--config", + pathToViteConfig, + ], { stdio: ["ignore", "inherit", "inherit"], env: { diff --git a/packages/studio/vite.config.ts b/packages/studio/vite.config.ts index 95a3ab95f..6d5fe3fa7 100644 --- a/packages/studio/vite.config.ts +++ b/packages/studio/vite.config.ts @@ -31,8 +31,5 @@ export default defineConfig((args: ConfigEnv): UserConfig => { css: { postcss: __dirname, }, - optimizeDeps: { - exclude: ["virtual_yext-studio", "virtual_yext-studio-git-data"], - }, }; });