[BUG] Updating to 1.4.3 breaks production build with Vite rollup error

See original GitHub issue

Describe the bug I updated to @shopify/hydrogen 1.4.3 from 1.4.2., and I’m getting the following error on production builds via Github Actions:

$ shopify hydrogen build --target node
[STARTED] Building node code
vite v2.9.15 building SSR bundle for production...
transforming...
✓ 38 modules transformed.
[vite]: Rollup failed to resolve import "/app/dist/client/index.html?raw" from "node_modules/@shopify/hydrogen/dist/esnext/platforms/virtual.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
[FAILED] [vite]: Rollup failed to resolve import "/app/dist/client/index.html?raw" from "node_modules/@shopify/hydrogen/dist/esnext/platforms/virtual.js".
[FAILED] This is most likely unintended because it can break your application at runtime.
[FAILED] If you do want to externalize this module explicitly add it to
[FAILED] `build.rollupOptions.external`

━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    [vite]: Rollup failed to resolve import "/app/dist/client/index.html?raw" from "node_modules/@shopify/hydrogen/dist/esnext/platforms/virtual.js".
    This is most likely unintended because it can break your application at runtime.
    If you do want to externalize this module explicitly add it to
    `build.rollupOptions.external`

To Reproduce

  • Create a production build, in my case, via Github Actions using ubuntu-latest as the build container.

Additional context Add any other context about the problem here. eg.

  • Hydrogen version: 1.4.3
  • Docker image: ubuntu-latest

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tylerscavecommented, Oct 4, 2022

It turns out the issue was with outdated shopify cli packages… Updating solved the build issue 👍 image

I’m now wrestling with a package from Builder.io that is causing some errors (but this is probably unrelated to hydrogen).

🛠️ Building the application... 
yarn run v1.22.19
$ shopify hydrogen build
[STARTED] Building client code
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
[TITLE] Built client code
[SUCCESS] Built client code
[STARTED] Building worker code
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
[TITLE] Built worker code
[SUCCESS] Built worker code
Done in 20.32s.
✅ Done in 20.[48](https://github.com/PaxLabs/pax-shopify-hydrogen/actions/runs/3184402346/jobs/5192759877#step:5:50)s.

🚀 Uploading deployment files... 
🛑 InvalidScriptError: retrying will not succeed. The following error must be actioned:

Uncaught Error: EvalError: Code generation from strings disallowed for this context
  at worker.mjs:2203:68269
Error: Process completed with exit code 1.

Thanks for the help getting through the build issue 🙏

1reaction
frandioxcommented, Sep 29, 2022

The only thing that changes from 1.4.2 to 1.4.3 is some implementation details of the Cart component so this might not be related to the version. Can you try using Node 18 and making sure node_modules is not cached? Also, can you check if /app/dist/client/index.html file exists after this error? It should be created during the build but before throwing this error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Updating to 1.4.3 breaks production build with Vite ...
The only thing that changes from 1.4.2 to 1.4.3 is some ... It should be created during the build but before throwing this...
Read more >
production build broken in Vite · Issue #5035 - GitHub
Was looking into this and this looks like an issue with vite js using roll-up plugin and hasn't been fixed yet, the recommended...
Read more >
Troubleshooting - Vite
Syntax Error / Type Error happens​​ Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This...
Read more >
vite failed to fetch dynamically imported module - You.com
One attempt to fix this issue, try to catch the error and force a reload to refetch the resource, but make sure to...
Read more >
How do I fix the npm UNMET PEER DEPENDENCY warning?
UNMET PEER DEPENDENCY error is thrown when the dependencies of one or more modules specified in the package.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found