This is a minimal reproduction of what seems to be an issue when using tsx with workspace dependencies that use alias.
This is a monorepo with two packages:
A package with aliased imports (tsconfig paths). Relevant files:
- src/config: a file required within the package
- src/testWithAlias.ts: it requires config using an alias
- src/testWithoutAlias.ts: it requires config using its relative path, without an alias
This packages uses tsx and depends on the dependency
package. Relevant files:
- src/thisFailsWithTsx.ts: it depends on the
dependency
package portion that uses aliases; this can be tested withpnpm tsxFail
- packages/main/src/thisWorksWithTsx.ts: it depends on the
dependency
package portion that does't use aliases; this can be tested withpnpm tsxOk
- packages/main/build.js: an esbuild build script for reference, which works on both cases (with and without aliases); this can be tested with
pnpm build && pnpm builtWithAlias