-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module resolution logic doesn't match tsc #4
Comments
Update on what I'm up to. Note that I'm ramping up in the node ecosystem, so feel free to let me know if I've done something weird, or missed something obvious. I took a few tries at fooling the typescript compiler in a similar way to what I'm now going to try the simpler (more sensble) approach, of just re-implementing the module lookup logic. My reading of the comment at https://github.com/microsoft/TypeScript/blob/master/src/compiler/types.ts#L5446 also makes me think that we're expected to implement all the logic ourselves. |
Hey! Thanks for digging into it. Sharing here what I posted on Discord:
|
Running into this same issue when importing from The file structure of the package is redux-saga-npm-1.1.3-f4b0ce38ee
└── node_modules
└── redux-saga
├── LICENSE
├── README.md
├── dist
├── effects
│ └── package.json
├── effects.d.ts
├── index.d.ts
└── package.json The // effects/package.json
{
"name": "redux-saga/effects",
"private": true,
"main": "../dist/redux-saga-effects-npm-proxy.cjs.js",
"module": "../dist/redux-saga-effects-npm-proxy.esm.js"
} Adding a types field resolves the issue, but is not needed with tsc: For anyone looking for a temporary solution:
|
thanks for the detailed writeup @skoging. I'm not working with typescript anymore, but I hope this helps the ts-pnp folks. |
ts-pnp adds a trailing slash. To quote the code,
ZIP file aren't part of PnP, but some Yarn idiosyncracy that this plugin accommodates, in so doing breaks this case of
|
The module resolution logic in
ts-pnp
doesn't match tsc. Noticed when trying to uselodash/fp
in a typescript project.The differences are:
lodash/fp
masks the file that should be imported -lodash/fp/fp.d.ts
See https://github.com/leightonsmith/ts-pnp-resolution-demo for more info, and reproduction steps.
I'm going to take a shot at fixing this.
The folder masking bit should be simple enough to address (if there's a file, prefer over a folder)
The typesVersion part will take more work, and is overlapping with functionality already present in typescript. Maybe the correct way to address both problems is to get typescript to handle it? At the moment, this plugin hands typescript the full path; maybe it'd work better to hand typescript the path to the package, and then let it handle it?
I'll keep you posted with progress.
The text was updated successfully, but these errors were encountered: