Skip to content

tsconfig paths resolution broken when using references: 'auto #221

Description

@arkadiusz-swierczek-pm

Description

Path alias resolution via tsconfig.json paths stopped working when upgrading from 1.11.0 to 1.12.2. The resolver returns no path for aliased specifiers (e.g. $/utils/helper) when references: 'auto' is set and the main tsconfig.json has a references array pointing to another tsconfig.

Relative imports (./utils/helper) still resolve correctly in both versions.

Reproduction

Minimal reproduction repo: https://github.com/arkadiusz-swierczek-pm/unrs-resolver-error

npm ci
node main.js

Setup

tsconfig.json — defines a $/* path alias and references tsconfig.node.json:

{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "paths": { "$/*": ["./src/*"] }
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

Resolver options:

const resolverOpts = {
  tsconfig: {
    configFile: 'tsconfig.json',
    references: 'auto',
  },
  extensions: ['.ts', '.tsx', '.js', '.jsx'],
};

Expected behavior

"$/utils/helper" → /path/to/test/src/utils/helper.ts

Actual behavior

Specifier v1.11.0 v1.12.2
$/utils/helper Resolves correctly no path
./utils/helper Resolves correctly Resolves correctly

Versions

  • Working: unrs-resolver@1.11.0
  • Broken: unrs-resolver@1.12.2
  • Platform: Windows 11, Node.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions