Comments (1)
Vite pre-bundles @shopify/hydrogen/client in standalone mode, but not in monorepo mode.
This is because, via its support for monorepos, considers other packages in the monorepo to be like local code.
As mentioned somewhere else, apparently, Vite has a special behavior when it encounters symlinks. And turns out our dev
project is basically using a symlink to run Hydrogen.
I could replicate the same behavior in a standalone app when moving <root>/node_modules/@shopify/hydrogen
to <root>/hydrogen
and creating a symlink with ln -s ../../hydrogen node_modules/@shopify/hydrogen
.
I've played a bit with Vite's preserveSymlink option but couldn't find anything interesting.
In any case, the changes in Shopify/hydrogen-archive#683 should bring closer the behavior of Vite in a standalone app to our dev
project. However, I'm not sure it fixes all the inconsistencies. We'll need to revisit each issue related to this and try.
optimizeDep.exclude Hydrogen SDK
This seems to be unnecessary after the changes mentioned above, because Vite doesn't need to optimize Hydrogen SDK anymore (since all the CJS dependencies are optimized, and Hydrogen itself is ESM --- or this is what I understand). -- Looks like it now always optimizes hydrogen/client in both standalone and dev, which I guess it's fine?
We could also check pnpm
since, at the very least, is way faster than Yarn 1 and is not deprecated. Installing a standalone app in my machine with Yarn takes about 50s, while pnpm is like 10s - 20s? However, I think it still uses symlinks for this kind of thing.
As a last resort, we could have a mechanism that copies shopify/hydrogen/dist/node
to shopify/dev/node_modules/@shopify/hydrogen/dist/node
or something like that. It's clunky but at least it should work π€·ββοΈ . It can be manual (yarn refresh && yarn dev
) or automatic with some kind of watcher π€
Edit: Just remembered about another hacky solution: yarn dev
writes to shopify/node_modules/@shopify/hydrogen/dist
direclty instead of shopify/hydrogen/dist
. I think the dev
project will be able to access that thanks to workspaces, and this is not a symlink anymore. I'm using something like this here π
from hydrogen-v1.
Related Issues (20)
- "Itβs missing some props that are..." (/api/hydrogen/components/cart/cartshoppaybutton)
- Shopify Hydrogen App crashes
- [BUG] CartCheckoutButton resolved to an invalid checkout page URL while BuyNowButton works fine HOT 5
- "CartLineProvider is not being given..." (/api/hydrogen/hooks/cart/usecartline)
- useQuery throws an error saying useQuery isn't exported when using in a custom hook HOT 2
- server-side redirects, preserving legacy Shopify URL patterns HOT 4
- [BUG] cannot obtain current URL in client code HOT 3
- [BUG] Oxygen is not defined Error on Deployment
- Hydrogen App not starting in Local Env. HOT 17
- [BUG] unclear docs regarding environment variable usage
- [BUG] 'Request Entity Too Large' error when POSTing to internal api routes HOT 1
- [BUG]
- Shop Pay Button not customizable with className provided HOT 1
- [BUG]
- [BUG] Back to Storefront from Checkout on Safari ios Error
- [BUG] linesRemove and linesAdd do not support promises
- [BUG]
- [BUG] HOT 2
- [BUG]
- [BUG]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hydrogen-v1.