@floating-ui/dom is broken with typescript 4.7 `node16` module resolution
See original GitHub issueWhen enabling "moduleResolution": "node16"
in tsconfig.json
, tsc now uses the exports
field of package.json
to look up imports.
So when i do:
import { arrow, autoUpdate, computePosition, flip, offset, shift, size } from '@floating-ui/dom';
If successfully finds it:
======== Module name '@floating-ui/dom' was successfully resolved to '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/index.d.ts' with Package ID '@floating-ui/dom/index.d.ts@0.5.1'. ========
But then it fails when @floating-ui/dom
wants to import @floating-ui/core/src/detectOverflow
(see https://github.com/floating-ui/floating-ui/blob/master/packages/dom/src/types.ts#L14):
======== Resolving module '@floating-ui/core/src/detectOverflow' from '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/src/types.d.ts'. ========
Explicitly specified module resolution kind: 'Node16'.
'baseUrl' option is set to '/Users/jzwartepoorte/Projects/dna', using this value to resolve non-relative module name '@floating-ui/core/src/detectOverflow'.
Resolving module name '@floating-ui/core/src/detectOverflow' relative to base url '/Users/jzwartepoorte/Projects/dna' - '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow'.
Loading module as file / folder, candidate module location '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow', target file type 'TypeScript'.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/src/package.json' does not exist according to earlier cached lookups.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/package.json' exists according to earlier cached lookups.
Loading module '@floating-ui/core/src/detectOverflow' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
File '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core/package.json' exists according to earlier cached lookups.
Export specifier './src/detectOverflow' does not exist in package.json scope at path '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core'.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/Projects/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
'baseUrl' option is set to '/Users/jzwartepoorte/Projects/dna', using this value to resolve non-relative module name '@floating-ui/core/src/detectOverflow'.
Resolving module name '@floating-ui/core/src/detectOverflow' relative to base url '/Users/jzwartepoorte/Projects/dna' - '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow'.
Loading module as file / folder, candidate module location '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow', target file type 'JavaScript'.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/src/package.json' does not exist according to earlier cached lookups.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/package.json' exists according to earlier cached lookups.
Loading module '@floating-ui/core/src/detectOverflow' from 'node_modules' folder, target file type 'JavaScript'.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/src/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/node_modules' does not exist, skipping all lookups in it.
File '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core/package.json' exists according to earlier cached lookups.
Export specifier './src/detectOverflow' does not exist in package.json scope at path '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core'.
Directory '/Users/jzwartepoorte/Projects/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jzwartepoorte/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@floating-ui/core/src/detectOverflow' was not resolved. ========
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
TypeScript module "Node16" does not resolve types of CJS ...
To expand on this, TypeScript 4.7.1-rc with nodenext module resolution is unable to resolve various NPM dependencies. See this example repo.
Read more >Add file extension when '--moduleResolution' is 'node16' or ...
TypeScript 4.7 checks package.json's type field and tsconfig's moduleResolution . So we need to insert the extension only if these two options are...
Read more >Typescript module resolution not working - Stack Overflow
Even though intellisense works fine in VSCode the transpiled javascript files throw an exception: Cannot find module . My project structure:.
Read more >Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can provide insight in diagnosing and solving problems.
Read more >TypeScript 4.7 crosses the finish line - InfoWorld
The latest version of Microsoft's strongly typed JavaScript introduces support for ECMAScript modules in Node.js, adds coding enhancements.
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
No, I’ve searched the codebase for any other
@floating-ui/core/src/....
imports, but there were none in any react packages.Thanks, I’ll look into
patch-package
.