Open gregory-j-baker opened 10 months ago
FYI: we figured out how to import GCDS into a Remix CJS server, see remix.config.js.
tldr: serverDependenciesToBundle: ['@cdssnc/gcds-components', '@cdssnc/gcds-components-react']
However, I will keep this issue open because I still think that providing .cjs
builds of your package is important, and will likely become even more important as frameworks migrate to react server components.
One more comment that might be helpful.
Thanks for raising this issue, we don't have much experience with Remix but will look into making integration into the framework easier.
The problem I reported is not specific to Remix. It's integration with CommonJS builds. I haven't verified this blog post, but it does seem to sum up the problem and offer a potential solution: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html.
Thanks, we will definitely use that as a reference when we take a look at the CommonJs package
Adding a comment here of a repository that uses remix: https://github.com/DTS-STN/canadian-dental-care-plan/tree/main/frontend
Adding a comment here of a repository that uses remix: https://github.com/DTS-STN/canadian-dental-care-plan/tree/main/frontend
For what it's worth, our project no longer uses CommonJS, so this repo isn't really relevant to this specific issue (anymore). 🤣
If you do need a remix project that uses CommonJS, I can deploy a stackblitz project or even create a small do-nothing project in my personal github account.
@gregory-j-baker we may not get to fixing this issue soon, but a small do-nothing project will be helpful and appreciated!
Just chatting a bit with @gregory-j-baker and in case someone else is trying to use GCDS with the latest remix, the configuration needed to get it to work is now in vite.config.js
. Here is my full working config:
export default defineConfig({
plugins: [remix(), tsconfigPaths()],
ssr: {
noExternal: ['@cdssnc/gcds-components', '@cdssnc/gcds-components-react'],
}
});
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:
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?