Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nx tsconfig paths alias resolution is not working as expected #28945

Open
1 of 4 tasks
Diboby opened this issue Nov 14, 2024 · 0 comments
Open
1 of 4 tasks

Nx tsconfig paths alias resolution is not working as expected #28945

Diboby opened this issue Nov 14, 2024 · 0 comments

Comments

@Diboby
Copy link

Diboby commented Nov 14, 2024

Current Behavior

Hello !

The @nx/vite/plugins/nx-tsconfig-paths.plugin path resolution is not working as expected.

I think the first tsconfig is supposed to be the project tsconfig (https://github.com/nrwl/nx/blob/master/packages/vite/plugins/nx-tsconfig-paths.plugin.ts#L117) but in my case, it resolves to the tsconfig under the workspace root foder.

Image

Expected Behavior

I think the first tsconfig is supposed to be the project tsconfig (https://github.com/nrwl/nx/blob/master/packages/vite/plugins/nx-tsconfig-paths.plugin.ts#L117) but in my case, it resolves to the tsconfig under the workspace root foder.

GitHub Repo

https://github.com/nrwl/nx/blob/master/packages/vite/plugins/nx-tsconfig-paths.plugin.ts#L117

Steps to Reproduce

  1. root tsconfig
{
  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2020", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": ".",
    "paths": {}
  },
  "exclude": ["node_modules", "tmp"]
}
  1. project tsconfig
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "allowJs": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "types": ["vite/client", "vitest"],
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ],
  "extends": "../../tsconfig.base.json"
}

Nx Report

Node           : 20.17.0
OS             : darwin-x64
Native Target  : x86_64-macos
npm            : 10.8.2

nx                 : 20.0.3
@nx/js             : 20.0.3
@nx/jest           : 20.0.3
@nx/eslint         : 20.0.3
@nx/workspace      : 20.0.3
@nx/cypress        : 20.0.3
@nx/devkit         : 20.0.3
@nx/eslint-plugin  : 20.0.6
@nx/react          : 20.0.3
@nx/vite           : 20.0.3
@nx/web            : 20.0.3
typescript         : 5.6.3
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/cypress/plugin
@nx/jest/plugin
---------------------------------------

Failure Logs

[Nx Vite TsPaths] Resolved @/contexts to undefined

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant