question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No package can be imported from CRA + TS projects

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
n1ru4lcommented, 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.

https://github.com/facebook/create-react-app/issues/10356

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

0reactions
strblrcommented, 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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

create-react-app should allow TypeScript imports outside `src`
just to document react-app-rewired/customize-cra workaround for anyone looking for a solution: add external typescript source dependencies into ...
Read more >
How to import shared typescript code using create-react-app ...
Setting baseDir in ts-config.json : Here create-react-app complains about: Your project's baseUrl can only be set to src or node_modules .
Read more >
Migrating from Create React App (CRA) to Vite
Learn how to migrate your CRA app over to Vite. ... No dedicated maintainer. ... Create a vite.config.ts at the root of your...
Read more >
Using React with TypeScript - Mattermost
Learn how to create a new TypeScript app with create-react-app and convert an existing create-react-app to TypeScript.
Read more >
Making Life Easier with Absolute Imports - React in Javascript ...
No Changes need to be done in VS Code. It will automatically import the config from jsconfig.json / tsconfig.json file. ESLint. CRA has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found