No package can be imported from CRA + TS projects
See original GitHub issueUsing 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:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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…
Yes it absolutely works!