Skip to content

Commit

Permalink
Ignore Cached Dependencies when Starting Studio. (#405)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tmeyer2115 and github-actions[bot] authored Oct 11, 2023
1 parent 42d4a97 commit 6e120f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 9 additions & 1 deletion packages/studio/bin/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 0 additions & 3 deletions packages/studio/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,5 @@ export default defineConfig((args: ConfigEnv): UserConfig => {
css: {
postcss: __dirname,
},
optimizeDeps: {
exclude: ["virtual_yext-studio", "virtual_yext-studio-git-data"],
},
};
});

0 comments on commit 6e120f2

Please sign in to comment.