We’re in the middle of trying a hack to rollback to the last working version of the container image for now. I’ll try the above method after this and get back with the outcome. It does seem to make sense. Thanks for the quick response though, Liam.
Topic summary
Builds of a Shopify app (Express template) started injecting require(“react”) into the Vite output, causing a browser runtime error: “Uncaught ReferenceError: require is not defined.” A screenshot shows the error; no other attachments are essential.
Attempts to mitigate included:
- Excluding suspect deps via Vite’s optimizeDeps.
- Confirming the app code doesn’t use require.
- Adding Vite’s CommonJS plugin.
- Considering a StackOverflow suggestion to transform require during asset build.
- Temporarily rolling back the container image (worked but not feasible).
Root cause and fix:
- Shopify’s internal teams identified the issue in their i18nFormat plugin for the i18next library (i18next is an internationalization framework; the plugin formats translations).
- A fix was shipped; updating @shopify/i18next-shopify to version 0.2.9 resolves the error.
Outcome:
- After updating the package, the app builds and loads correctly.
Status and actions:
- Resolved. Developers should update @shopify/i18next-shopify to 0.2.9.
- If the issue persists after updating, report back.