Closed bnason closed 3 months ago
Hello @bnason, I don't have experience with pnpm at all, so I don't know how pnpm workspaces works, but if I'm not wrong, as you are running pnpm start
inside package/a
and pnpm start
is basically node --no-warnings --loader ts-paths-esm-loader --experimental-specifier-resolution=node --experimental-fetch src/index.ts
, ts-paths-esm-loader
will only work for files inside packages/a
, and @test/b
will be considered an "external" module, so it will not do any transformation on it.
So, as it is pnpm workspaces that "maps" your packages between each other, maybe the solution for you is to find a way to add ts-paths-esm-loader
as a loader for pnpm workspaces mapping
When using a pnpm monorepo where multiple projects are using
ts-paths-esm-loader
and projecta
imports from projectb
, I believe the paths from b are being resolved relative to projectsa
s path. I've created a demo project here: https://stackblitz.com/edit/json-server-dv21mg?file=packages/b/src/index.tsIf you open the terminal and go into
packages/a
and runpnpm start
you will see the error below. However, if you switch the export to the one that uses the relative path and rerunpnpm start
, it works correctly.It seems like this is also a problem in
tsconfig-paths
https://github.com/dividab/tsconfig-paths/issues/153