Incorrectly passes `bundler` even if `exports.*.types` is missing
fregante opened this issue · comments
See https://arethetypeswrong.github.io/?p=css-selector-generator%403.6.4
From what I see, moduleResolution:bundler
and node16
actually fails if the types are not specified in the exports
map, but this tool passes them both.
![Screenshot](https://private-user-images.githubusercontent.com/1402241/278234605-92d2df64-b52e-4085-9f05-ae1797ba1a14.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI5NDA3MTcsIm5iZiI6MTcyMjk0MDQxNywicGF0aCI6Ii8xNDAyMjQxLzI3ODIzNDYwNS05MmQyZGY2NC1iNTJlLTQwODUtOWYwNS1hZTE3OTdiYTFhMTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MDZUMTAzMzM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODI2MzI1MTZlYTNhNzU3NzIxMGIyMDkzMmQ0ODJiZjA0NmMwZWEzM2E4MTk0NGFjN2IyMWI0YmI2NzJhNmM1YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.zXq0w0rWqJFzg_HMoQKH8yYiMuqXt2iAmXpJN5JFp5Q)
I submitted a PR to fix it https://togithub.com/fczbkk/css-selector-generator/pull/577/files
These resolutions are working correctly (both in tsc and in this tool) via file extension substitution. The import
condition specifies ./esm/index.js
, so TypeScript will successfully find ./esm/index.d.ts
.
Uhm, that's not what I'm seeing.
CI results: can't find the types
https://github.com/pixiebrix/pixiebrix-extension/actions/runs/6650563402/job/18070905027#step:5:1
The error message is very clear:
There are types at '/home/runner/work/pixiebrix-extension/pixiebrix-extension/node_modules/css-selector-generator/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'css-selector-generator' library may need to update its package.json or typings.
This is the tsconfig: it worked when the resolution was just node
but not on bundler
The module can only be correctly imported by TypeScript after making the exports
suggested in the linked PR.
@andrewbranch if you're interested in resolving this I can work on a repro
All the files where the error appears are CJS files, so the errors you’re seeing correspond to the node16 (from CJS): ❌ No types
row.
Oh wait, but your moduleResolution is set to bundler
there? Something weird is going on. But it’s definitely something in your project, not this tool—the results from the tool match what I see looking at the source code. The results in CI are surprising. Try adding --traceResolution
to the tsc
invocation?