aleclarson / vite-tsconfig-paths

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

Rollup failed to resolve import #148

Open rexkenley opened 1 month ago

rexkenley commented 1 month ago

I am getting a "rollup failed to resolve import" error. Can you please show me what I did wrong?

vite.config.ts image

tsconfig.app.json image

tsconfig.json image

tsc -b returns ok

When I run vite build, I get the error. image

achimstraussdmb2bcom commented 1 month ago

same problem. Problems since upgrade of typescript from 5.4.x to 5.5.x.

My tsconfig:

{
    "compilerOptions": {
        "composite": true,
        "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
        "skipLibCheck": true,
        "module": "ESNext",
        "moduleResolution": "bundler",
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "noEmit": true,
        "baseUrl": "./src",
        "paths": {
            "pages/*": [
                "pages/*"
            ],
            "contexts/*": [
                "contexts/*"
            ],
            "components/*": [
                "components/*"
            ],
            "services/*": [
                "services/*"
            ],
            "hooks/*": [
                "hooks/*"
            ],
            "i18n/*": [
                "i18n/*"
            ],
            "operations/*": [
                "operations/*"
            ],
            "src/*": [
                "*"
            ]
        }
    },
    "types": [
        "vitest/globals"
    ],
    "include": ["vite.config.ts"]
}
codethief commented 3 weeks ago

I can't get it to work, either, but switching back to TypeScript 5.4.2 doesn't seem to fix it @achimstraussdmb2bcom. FWIW, since I make extensive use of extends and TSC project references, which has been causing issues in many other tools¹, I also tried explicitly setting projects / configNames to the tsconfigs that actually contain the path aliases, and I also tried enabling parseNative. But nothing has worked so far.

¹) EDIT: I see that vite-tsconfig-paths actually takes projects references into account, so I think my suspicion is unjustified and the issue must be elsewhere.