Remix app using Hydrogen from Shopify: Import Dynamix npm package commonjs with the new ES type=module #9674
Unanswered
pascalcortezvi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there I have a problem dealing with this npm package from Sanity. Here's my sanity.js file:
import createClient from '@sanity/client';
import imageUrlBuilder from '@sanity/image-url';
export const sanityClient = createClient({
projectId: 'I won't put my project id here',
dataset: 'production',
useCdn: true,
apiVersion: '2022-03-07',
});
const builder = imageUrlBuilder(sanityClient);
When I use the createClient from @sanity/client it works good and I can use it to fetch data no problem. As soon as I add this:
import imageUrlBuilder from '@sanity/image-url';
const builder = imageUrlBuilder(sanityClient);
The app won't accept it and will tell this:
TypeError: vite_ssr_import_1.default is not a function
Here's the doc from Sanity for the image builder:
https://www.sanity.io/docs/image-url#sanity-image-url
I saw video on youtube from Remix Youtube channel explaining two solutions using the ssr noexternal from Vite JS and also a package to interop the package going into Vite SSR. Nothing worked. I'm stucked I don't know what to do with it. Anyone?
Can someone can help me? I think the problem is related with the way Sanity export their package VS Vite JS using the SSR.
Beta Was this translation helpful? Give feedback.
All reactions