ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

Not able to extend config from packages having subpath exports map

Open kwonoj opened this issue 1 year ago • 0 comments

Search Terms

tsconfig, extends, workspaces, exports, subpath

Expected Behavior

ts-node should able to resolve if extends: points to the workspace package have subpath exports map.

// Some package uses config
{
  "extends": "@test/tsconfig/tsconfig.json",
}
//@test/tsconfig/package.json

{
  "name": "@test/tsconfig",
  "version": "0.0.0",
  "license": "UNLICENSED",
  "private": true,
  "exports": {
    ".": "./tsconfig.base.json",
    "./tsconfig.json": "./tsconfig.base.json",
    "./tsconfig.cjs.json": "./tsconfig.cjs.json"
  }
}

Actual Behavior

Not able to resolve modules.

Steps to reproduce the problem

https://github.com/kwonoj/wallaby-workspace-test

yarn

// check plain ts-node behavior
npx ts-node ./packages/pkg-core/src/index.ts

// jest with ts-node
yarn workspace @test/core run test-jest

Minimal reproduction

See above

Description

Related with https://github.com/TypeStrong/ts-node/pull/2091. In the PR, It sets conditions to undefined (https://github.com/TypeStrong/ts-node/pull/2091/files#diff-47fe05042c9c335713e6ad6b3933e31a4b4f870f0892d2614d28312b36e4b239R51) - which makes ts to set noderesolution feature to None (https://github.com/microsoft/TypeScript/blob/d701d908d534e68cfab24b6df15539014ac348a3/src/compiler/moduleNameResolver.ts#L1787).

This effectively disables all of node.js package.json's subpath exports (https://github.com/microsoft/TypeScript/blob/v5.7.2/src/compiler/moduleNameResolver.ts#L1685-L1689) either local (#imports) or exports. So if any package have exports / imports subpath map / alias, tsconfig extending it will fail to resolve module.

kwonoj avatar Jan 02 '25 07:01 kwonoj