Coder Social home page Coder Social logo

Comments (1)

frandiox avatar frandiox commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.