Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No package can be imported from CRA + TS projects #754

Closed
strblr opened this issue Oct 24, 2021 · 7 comments · Fixed by #755
Closed

No package can be imported from CRA + TS projects #754

strblr opened this issue Oct 24, 2021 · 7 comments · Fixed by #755

Comments

@strblr
Copy link

strblr commented Oct 24, 2021

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.

@n1ru4l
Copy link
Owner

n1ru4l commented Oct 24, 2021

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...

@strblr
Copy link
Author

strblr commented Oct 24, 2021

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

@stsiarzhanau
Copy link

stsiarzhanau commented Oct 26, 2021

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)

@strblr
Copy link
Author

strblr commented Oct 26, 2021

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

@stsiarzhanau
Copy link

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

Thanks. That helped.

@n1ru4l
Copy link
Owner

n1ru4l commented Oct 28, 2021

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

@strblr
Copy link
Author

strblr commented Oct 28, 2021

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

Yes it absolutely works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants