aleclarson / vite-tsconfig-paths

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

Version 3.3.3 broke my app #18

Closed lanthaler closed 3 years ago

lanthaler commented 3 years ago

... while 3.3.2 is still working fine. I'm getting the following error on vite build:

[vite]: Rollup failed to resolve import "@pages/TestPage.vue" from "src/router.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "@pages/TestPage.vue" from "src/router.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at onRollupWarning (/workspaces/test-app/node_modules/vite/dist/node/chunks/dep-1bdbec90.js:46664:19)
    at Object.onwarn (/workspaces/test-app/node_modules/vite/dist/node/chunks/dep-1bdbec90.js:46514:17)
    at Object.onwarn (/workspaces/test-app/node_modules/rollup/dist/shared/rollup.js:19639:20)
    at ModuleLoader.handleResolveId (/workspaces/test-app/node_modules/rollup/dist/shared/rollup.js:18719:26)
    at /workspaces/test-app/node_modules/rollup/dist/shared/rollup.js:18686:22
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 1)
    at async ModuleLoader.fetchStaticDependencies (/workspaces/test-app/node_modules/rollup/dist/shared/rollup.js:18684:34)
    at async Promise.all (index 0)
    at async ModuleLoader.fetchModule (/workspaces/test-app/node_modules/rollup/dist/shared/rollup.js:18661:9)

If I run DEBUG=vite-tsconfig-paths yarn vite as suggested in the README, I get the following corresponding error:

 > src/router.ts:3:40: error: No loader is configured for ".vue" files: src/pages/TestPage.vue
    3 │ import TestPage from '@pages/TestPage.vue'
      ╵      

but there are also a number of errors such as

 > html:/workspaces/test-app/src/App.vue:4:23: error: Could not resolve "@components/Card.vue" (the plugin "vite:dep-scan" didn't set a resolve directory)
    4 │ import Card from '@components/Card.vue'
      ╵                  ~~~~~~~~~~~~~~~~~~~~~~
aleclarson commented 3 years ago

What do the logs look like with DEBUG=vite-tsconfig-paths? You can leave out the resolved logs. Just need the ones at the start. And are you using include and exclude? I just fixed those in v3.3.3.

aleclarson commented 3 years ago

You're probably using include/exclude. I just fixed two glob-related bugs. Let me know if that helps.

Dreamacro commented 3 years ago

it's also broken my app, https://github.com/Dreamacro/clash-dashboard

You can test it with this project (upgrade to the latest dependency)

Dreamacro commented 3 years ago

it has broken on 3.3.4, works on 3.3.3

aleclarson commented 3 years ago

@Dreamacro First, upgrade to 3.3.6 and see if that helps. If not...

Follow the instructions in Troubleshooting, and paste the logs here.

You can also write a failing test here and open a PR with it (no fix necessary).

git clone https://github.com/aleclarson/vite-tsconfig-paths
cd vite-tsconfig-paths
pnpm install
yarn test --watch -i