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

[5.1.1] vite-tsconfig-paths stopped understanding my paths #162

Closed
burtek opened this issue Nov 9, 2024 · 5 comments
Closed

[5.1.1] vite-tsconfig-paths stopped understanding my paths #162

burtek opened this issue Nov 9, 2024 · 5 comments

Comments

@burtek
Copy link

burtek commented Nov 9, 2024

With 5.1.0 vite-tsconfig-paths correctly parses paths, prints them when DEBUG is enabled, app works, vitest works.
With 5.1.1 vite-tsconfig-paths no longer prints the paths in DEBUG output and both app and vitest tests stopepd working.

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "types": ["vite/client", "vitest/globals"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "baseUrl": ".",
    "paths": {
      "@@api/*": ["api/*"],
      "@@components/*": ["src/components/*"],
      "@@config/*": ["config/*"],
      "@@data/*": ["src/data/*"],
      "@@shared-utils/*": ["shared-utils/*"],
      "@@locales/*": ["public/locales/*"],
    }
  },
  "include": [
    "api",
    "config",
    "src",
    "*.config.ts",
    "shared-utils"
  ]
}

DEBUG output - diff between 5.1.0 and 5.1.1

  vite-tsconfig-paths options.root   == undefined +0ms
  vite-tsconfig-paths project root   == K:/project +1ms
  vite-tsconfig-paths workspace root == K:/project +0ms
  vite-tsconfig-paths projects: [ 'K:\\project\\tsconfig.json' ] +27ms
  vite-tsconfig-paths config loaded: {
  configPath: 'K:/project/tsconfig.json',
  config: {
    compilerOptions: {
      target: 'ESNext',
      lib: [ 'dom', 'dom.iterable', 'esnext' ],
      types: [ 'vite/client', 'vitest/globals' ],
      allowJs: true,
      skipLibCheck: true,
      esModuleInterop: true,
      allowSyntheticDefaultImports: true,
      strict: true,
      forceConsistentCasingInFileNames: true,
      noFallthroughCasesInSwitch: true,
      module: 'esnext',
      moduleResolution: 'node',
      resolveJsonModule: true,
      isolatedModules: true,
      noEmit: true,
      jsx: 'react-jsx',
      baseUrl: 'K:/project',
      paths: {
        '@@api/*': [ 'api/*' ],
        '@@components/*': [ 'src/components/*' ],
        '@@config/*': [ 'config/*' ],
        '@@data/*': [ 'src/data/*' ],
        '@@shared-utils/*': [ 'shared-utils/*' ],
        '@@locales/*': [ 'public/locales/*' ]
      }
    },
    include: [ 'api', 'config', 'src', '*.config.ts', 'shared-utils' ]
  }
} +5ms
  vite-tsconfig-paths compiled globs: {
  includers: [
-    /^\.\/api\/((?:[^/]*(?:\/|$))*)$/,
-    /^\.\/config\/((?:[^/]*(?:\/|$))*)$/,
-    /^\.\/src\/((?:[^/]*(?:\/|$))*)$/,
-    /^\.\/([^/]*)\.config\.ts$/,
-    /^\.\/shared-utils\/((?:[^/]*(?:\/|$))*)$/
+    /^\.\.\/\.\.\/\.\.\/api\/((?:[^/]*(?:\/|$))*)$/,
+    /^\.\.\/\.\.\/\.\.\/config\/((?:[^/]*(?:\/|$))*)$/,
+    /^\.\.\/\.\.\/\.\.\/src\/((?:[^/]*(?:\/|$))*)$/,
+    /^\.\.\/\.\.\/\.\.\/([^/]*)\.config\.ts$/,
+    /^\.\.\/\.\.\/\.\.\/shared-utils\/((?:[^/]*(?:\/|$))*)$/
  ],
  excluders: [
    /^\.\/((?:[^/]*(?:\/|$))*)node_modules\/((?:[^/]*(?:\/|$))*)$/,
    /^\.\/((?:[^/]*(?:\/|$))*)bower_components\/((?:[^/]*(?:\/|$))*)$/,
    /^\.\/((?:[^/]*(?:\/|$))*)jspm_packages\/((?:[^/]*(?:\/|$))*)$/
  ]
} +3ms

 DEV  v2.1.4 K:/project

-  vite-tsconfig-paths resolved: {
-  id: '@@config/test-utils',
-  importer: 'K:/project/src/components/speeddial/hooks/__tests__/use-draft.test.ts',
-  resolvedId: 'K:/project/config/test-utils.tsx',
-  configPath: 'K:/project/tsconfig.json'
-} +2s
-  vite-tsconfig-paths resolved: {
-  id: '@@data/index',
-  importer: 'K:/project/src/components/speeddial/components/__tests__/add-tile.test.tsx',
-  resolvedId: 'K:/project/src/data/index.ts',
-  configPath: 'K:/project/tsconfig.json'
-} +67ms
-  vite-tsconfig-paths resolved: {
-  id: '@@data/speeddial/slice',
-  importer: 'K:/project/src/components/speeddial/components/__tests__/add-tile.test.tsx',
-  resolvedId: 'K:/project/src/data/speeddial/slice.ts',
-  configPath: 'K:/project/tsconfig.json'
-} +0ms
-  vite-tsconfig-paths resolved: {
-  id: 'src/theme',
-  importer: 'K:/project/config/test-utils.tsx',
-  resolvedId: 'K:/project/src/theme/index.tsx',
-  configPath: 'K:/project/tsconfig.json'
-} +31ms
-  vite-tsconfig-paths resolved: {
-  id: 'src/data/index',
-  importer: 'K:/project/src/components/speeddial/components/__tests__/add-tile.test.tsx',
-  resolvedId: 'K:/project/src/data/index.ts',
-  configPath: 'K:/project/tsconfig.json'
-}

 <vitest output follows>

There is a change in includers, can that be the reason?

@ivancea
Copy link

ivancea commented Nov 9, 2024

+1 here. After some testing, this change:
8c40fee#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R292-R293
Looks like the culprit.

The call to resolve("C:/a/b/c/d", "**/*.ts") returns something like ../../../../../**/*.ts

@aleclarson
Copy link
Owner

I will release a new patch version after a Windows user confirms that the latest commit fixes the issue for them. 👍

@burtek
Copy link
Author

burtek commented Nov 9, 2024

I can test that tomorrow

@ivancea
Copy link

ivancea commented Nov 10, 2024

@aleclarson Windows 11 user here with relative paths in tsconfig. Those changes work for me. Thanks!

@king8fisher
Copy link

thank you for such a quick fix!

renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Nov 11, 2024
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | vite-tsconfig-paths | 5.1.1 | 5.1.2 |


## [v5.1.2](https://github.com/aleclarson/vite-tsconfig-paths/releases/tag/v5.1.2)

-   fix Windows regression introduced in v5.1.1 ([#162](aleclarson/vite-tsconfig-paths#162))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants