gcds-components
gcds-components copied to clipboard
No support for CommonJS package types
Today I tried to integrate GCDS with my Remix application and ran into the following issue when Remix tried to render a component server-side:
/home/{...}/node_modules/@cdssnc/gcds-components-react/dist/index.js:4
import { createReactComponent } from './react-component-lib';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/home/gbaker/Projects/github/dts-stn/canadian-dental-care-plan/frontend/app/routes/gcds-test.tsx:1:28)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
The problem is that my custom server must be compiled as CommonJS (for technical reasons), so when it tries to render a GCDS component, it fails.
Have you considered shipping a hybrid package that contains both .mjs
and .cjs
variants, so those of us stuck using CommonJS on the server can still use GCDS?