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

General fixes before releasing #1974

Merged
merged 9 commits into from
Apr 11, 2024
5 changes: 5 additions & 0 deletions packages/hydrogen/src/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export function hydrogen(pluginOptions: HydrogenPluginOptions = {}): Plugin[] {
],
},
},
// Vite performs an initial reload after optimizing these dependencies.
// Do it early to avoid the initial reload:
optimizeDeps: {
include: ['@shopify/hydrogen'],
},
Comment on lines +73 to +75
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll be honest and I don't quite understand what's going on here. It seems vite automatically recognizes the mono repo and does not pre-bundle @shopify/hydrogen dependencies. include forces them to be pre-bundled. How does that affect initial reload?

Copy link
Contributor Author

@frandiox frandiox Apr 11, 2024

Choose a reason for hiding this comment

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

Vite decides to optimize Hydrogen (I'm not really sure why) when it's used outside of our monorepo. You can see this in the demo-store:

image

This just lets Vite find the dependency and optimize it earlier to avoid the initial refresh.

};
},
api: {
Expand Down
Loading