n1ru4l/graphql-live-query

No package can be imported from CRA + TS projects

Closed this issue · 7 comments

Using the latest react-scripts and TypeScript versions, importing something from graphql-live-query-patch-json-patch for example seems to fail no matter what.

Copy/pasting from the doc:

import { applyLiveQueryJSONPatch } from "@n1ru4l/graphql-live-query-patch-json-patch";

I get the following error:

Failed to compile.

./node_modules/@n1ru4l/graphql-live-query-patch-json-patch/index.mjs
Can't import the named export 'createApplyLiveQueryPatch' from non EcmaScript module (only default export is available)

I tried several import strategies (* as jsonPatch, importing sub-paths, etc.), the problem stays the same. It happens for all graphql-live-query packages I tried.

This seems to be a known issue with webpack (which is used by create-react-app). It seems to not like the .mjs extension.

facebook/create-react-app#10356

I am currently looking into how we can avoid this, while not breaking platforms such as Node.js...

Awesome, thank you. Please let me know when you publish the fix.

I encouter similar error when trying to import some hooks from @shopify/react-form and use them in my CRA + TS project.

./node_modules/@shopify/react-form/build/esm/validation/validator.mjs Can't import the named export 'isEmpty' from non EcmaScript module (only default export is available)

@stsiarzhanau While this is being fixed, you can try this ugly hack: formatjs/formatjs#1395 (comment)

@stsiarzhanau While this is being fixed, you can try this ugly hack: formatjs/formatjs#1395 (comment)

Thanks. That helped.

Hey @stsiarzhanau and @ostrebler! Can you please confirm the package versions published here #755 (comment) work for you?

Hey @stsiarzhanau and @ostrebler! Can you please confirm the package versions published here #755 (comment) work for you?

Yes it absolutely works!