Shopify App Build issue

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.
Summarized with AI on January 12. AI used: gpt-5.

Thank you Liam for the solution. After we tried the hack we mentioned earlier, it worked but was not a feasible approach. We updated the version number afterwards for the package you mentioned and it worked like a charm.