aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.24k stars 43 forks source link

Cannot resolve paths of submodule. #63

Closed profispojka closed 1 year ago

profispojka commented 1 year ago

When I created git submodule, I tried to use this plugin to correctly resolve paths of the submodule. But unfortunately I am getting this error: image

All the paths, but the submodule paths, seems to be resolving correctly.

My vite config (main project):

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vuetify from '@vuetify/vite-plugin'
import { vueAndTsChecker } from 'vite-plugin-typescript-vue-checker';
import tsconfigPaths from 'vite-tsconfig-paths'

// eslint-disable-next-line
export default defineConfig({
  plugins: [
    vue(),
    // https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
    vuetify({ autoImport: true }),
    vueAndTsChecker(),
    tsconfigPaths({
      projects: [
        './tsconfig.json',
        './submodule/lil-mole/tsconfig.json'
      ]
    }),
  ],
})

ts config (main project):

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": ["cypress", "node"],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "cypress/**/*.ts",
    "cypress/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ],
  "rootDirs": ["src/", "submodule/lil-mole/"]
}

ts config (submodule):

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": ["cypress"],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "cypress/**/*.ts",
    "cypress/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
aleclarson commented 1 year ago

Have you tried the loose: true option?

profispojka commented 1 year ago

Tried it. Unfortunately does not seem to be working.

aleclarson commented 1 year ago

Can you reproduce this in the ./demo folder please 👍