Hi,
I’m building a Shopify embedded app using the official Remix template (Client-Side Rendering only) and trying to integrate @shopify/polaris-viz for charts.
However, importing any Polaris Viz chart immediately causes a Vite bundling error.
Error:
require() of ES Module /node_modules/d3-scale/src/index.js
from /node_modules/
/polaris-viz-core/build/cjs/utilities/createGradient.js
not supported.
Instead change the require of index.js in
/polaris-viz-core/build/cjs/utilities/createGradient.js
to a dynamic import() which is available in all CommonJS modules.
Environments
- Shopify embedded app
- Remix template (CSR only – no SSR)
- Vite bundler
- Polaris Viz: latest version
- Node: (your version)
- OS: Ubuntu
Issue Summary
Polaris Viz core (polaris-viz-core) includes CJS files that use require(), but D3 packages are ESM-only.
This causes Vite to throw the error during pre-bundling, even though I’m using CSR only.
Question
Is there an official recommended configuration for using Polaris Viz with the Shopify Remix template (CSR)?
Or should Polaris Viz update its CJS build to support loading ESM modules like D3?
Any guidance or package updates would be appreciated.
Thanks!