-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
ts-node not supporting Yarn's pnp mode #1444
Comments
yarn pnp makes some very aggressive changes to the node environment, even modifying typescript itself. What changes do you think need to happen in yarn's PnP or in ts-node to support this? |
I am not very familiar with PnP or with the inner workings of ts-node's module resolution, but on this yarn page they are saying this:
|
Here are some pointers to kick-start your investigation: The error you're seeing is coming from TypeScript's module resolver within TypeScript's typechecker, not node's module resolver. (EDIT this erroneously said "yarn's module resolver", but it should be "node") yarn needs to monkey-patch typescript to add PnP support to TypeScript's module resolver. In this case, when yarn's docs talk to a "library author", it is directed at the TypeScript team. However, the TypeScript team has chosen not not merge yarn PnP support, which necessitates yarn's monkey-patching. We wrap TypeScript's module resolver to reclassify modules as internal/external, but mapping from module specifiers to absolute paths is still happening via TypeScript's API, so is handled by TypeScript with yarn's patches. ts-node/src/resolver-functions.ts Lines 92 to 99 in aaf6052
This could be a yarn bug, or could be a ts-node bug. It is unlikely that ts-node needs to use the PnP API directly, since we delegate all resolutions to either Typescript's or node's resolution APIs, and both of those APIs are being monkey-patched by yarn PnP. |
Thanks a lot! Seems like they must have resolved (no pun intended) this issue in 3.1.0. |
Search Terms
yarn pnp webpack
Expected Behavior
Expected ts-node / webpack to simply work with pnp. Unfortunately not the case.
Actual Behavior
It is unable to find any modules referenced in my webpack.config.ts
Steps to reproduce the problem
create a typescript file, such as for example:
import * as path from path; console.log(path)
, use Yarn v2's pnp as nodeLinker, create an empty tsconfig.json (can also be thetsc --init
version or really any tsconfig) try to run ts-node on this program.Minimal reproduction
https://github.com/luxalpa/ts-node-bug
Specifications
The text was updated successfully, but these errors were encountered: