Skip to content

Not able to extend config from packages having subpath exports map #2146

@kwonoj

Description

@kwonoj

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 #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions