-
Notifications
You must be signed in to change notification settings - Fork 295
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
[VITE] Missing dependencies after running setup vite command #1834
Comments
Unable to reproduce on my end. Base on the error, it feels like your |
@wizardlyhel I forgot to mention that I'm using pnpm |
Oh, interesting, thanks for reporting this. I'll play a bit with this and try it with PNPM. For the time being, if you install those dependencies manually it should work. |
So I've tried in different ways with PNPM and I wasn't able to reproduce this issue. ❯ pnpm -v
8.10.2
❯ node -v
v18.17.1 What versions are you using? |
I created a clean new project following the steps in my first comment and still have the same dependency issue.
|
I am getting the same error: ReferenceError: exports is not defined Mine is caused by the typographic-base package, is there any fix for this yet? |
That's probably unrelated to this specific issue. For the typographic-base dependency, check how we updated our demo-store to Vite: Shopify/hydrogen-demo-store#12 |
@thomasKn You mentioned you are using PNPM but the steps you wrote are using NPM. You are installing dependencies with PNPM, right? I've tried again with the same steps (NPM) and then running These are the steps I tried:
Then it seems to work: ![]() Am I doing anything wrong with the steps listed? |
I was able to reproduce this finally in our demo-store. The problem is not related to Hydrogen, though, so we can't fix much here I think. The issue is that Vite tries to find dependencies to optimize in Try adding the following to your
You might need to add more dependencies, depending on what you are using in your project. |
Thanks @frandiox I added the Although I still have the
|
Are you adding |
Yeah sorry I didn't try to remove |
@frandiox This is still an issue for us unfortunately. For context, we're using a PNPM monorepo. There's another (non-Hydrogen) Remix Vite app in the same monorepo that works without any issue (and uses many of the same deps), so I suspect these errors are being introduced by the It's like a game of whack-a-mole. We were able to get rid of the errors for
|
I agree it's frustrating but this is really an issue with the dependencies. They are in CJS, which means they are only compatible with Node.js. Oxygen is a different runtime so you need to tell Vite to do its magic before loading the code in Oxygen. That said, I'm trying to add here a tool to do all this job automatically: #2106 |
The Oxygen dev runtime is based on |
That's right
The template you mention doesn't run on workerd. The Running on different runtimes in dev vs prod can lead to bugs harder to debug, such as In fact, once running locally on workerd becomes a standard and tested Vite plugin, I believe the Remix team will switch to that instead of polyfilling, which was supposed to be a temporary patch for a bigger problem. |
Got it, thanks for clarifying. Will keep an eye on your PR as this is the only blocker for us switching to Vite |
What is the location of your example repository?
No response
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
"@shopify/hydrogen": "~2024.1.3"
What version of Remix are you using?
"@remix-run/node": "^2.8.0"
Steps to Reproduce
npm create @shopify/hydrogen@latest
npx shopify hydrogen setup vite
npm run dev
Expected Behavior
Hydrogen app should launch correctly.
Actual Behavior
Missing dependencies:
ReferenceError: exports is not defined
The text was updated successfully, but these errors were encountered: