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.

Typescript@beta moduleResolution nodenext strategy breaks @emotion

See original GitHub issue

Current behavior:

  • setting tsconfig.json.moduleResolution = node: everything is fine
  • setting tsconfig.json.moduleResolution = nodenext: throws error
./src/app.tsx 13:2-15:21
[tsl] ERROR in /somedir/nirv/src/app.tsx(13,3)
      TS2307: Cannot find module '@emotion/react/jsx-runtime' or its corresponding type declarations.

Expected behavior:

Environment information:

  • react version:18.1
  • @emotion/react version:18.1
  • typescript: beta
  • tsc: Version 4.7.0-dev.20220430
  • pnpm: 6.32.9

** tsconfig **


{
  "include": ["src"], 
  "exclude": ["src/**/*.test.ts"],
  "compileOnSave": false,
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "alwaysStrict": true,
    "baseUrl": "./", 
    "checkJs": false,
    "esModuleInterop": true,
    "exactOptionalPropertyTypes": false,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "jsxImportSource": "@emotion/react",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext", 
    "moduleResolution": "nodenext", <-------- breaks @emotion 
    "noFallthroughCasesInSwitch": false,
    "noImplicitAny": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noPropertyAccessFromIndexSignature": false,
    "outDir": "dist",
    "paths": {},
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "es2017", 
    "typeRoots": ["./src/@types", "./node_modules/@types"]
  }
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, May 1, 2022

So the way to fix this would be to add the appropriate package.json#exports. This is, sort of, worked on here: https://github.com/preconstruct/preconstruct/pull/435

1reaction
srmaguracommented, May 1, 2022

Thanks for the report, I can confirm this is an issue. Minimal repro: https://github.com/srmagura/emotion-nodenext-repro

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import ... There are two possible module resolution strategies: Node...
Read more >
cannot find module '@emotion/react/jsx-runtime' or its ...
emotion -js/emotionTypescript@beta moduleResolution nodenext strategy breaks @emotion#2742. Created 8 months ago. 6. Current behavior: setting tsconfig.json.
Read more >
tsc-esm-fix - npm
meta is not allowed. esbuild/1043: empty output for interface files that breaks reimport. moduleResolution: nodenext. Nightly build TypeScript ...
Read more >
Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can ... TypeScript will adopt the Node.js run-time resolution strategy by ...
Read more >
TypeScript - xstyled
Read styled-components TypeScript guide to learn more about it. Use TypeScript with Emotion. Create a declaration file. // styled.
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