[plugin vite:dep-scan] Cannot read properties of undefined (reading 'length')
cool1809 opened this issue · 9 comments
"type": "module",
"vite-aliases": "^0.10.0",
"vite": "4.0.3",
[plugin vite:dep-scan] Cannot read properties of undefined (reading 'length')
../../node_modules/.pnpm/esbuild@0.16.13/node_modules/esbuild/lib/main.js:1357:21:
1357 │ let result = await callback({
╵ ^
This error came from the "onResolve" callback registered here:
../../node_modules/.pnpm/esbuild@0.16.13/node_modules/esbuild/lib/main.js:1281:20:
1281 │ let promise = setup({
╵
import { ViteAliases } from "vite-aliases";
// import { ViteAliases } from "../node_modules/vite-aliases";
Problems Persist.
@cool1809 What does your configuration of Vite and the Plugin itself look like?
This looks more like a issue regarding optimizeDeps
rather then vite-aliases.
@Subwaytime The correct log will be generated, but the project will not run
{
// dir: "../../apps",
dir: "src",
prefix: "@",
deep: true,
depth: 1,
createLog: true,
logPath: "src/logs",
createGlobalAlias: false,
adjustDuplicates: false,
useAbsolute: false,
useIndexes: false,
useConfig: false,
useTypescript: true,
root: process.cwd()
}
Hm, try excluding or including it in optimizeDeps
inside your vite.config
optimizeDeps: {
include: ['vite-aliases'],
},
Note: usually this isnt needed, so i am wondering what the cause of this is, as the example
and other projects seem to work fine.. 🤔
A temporary solution
I tried to get the version down to 0.9.2 and the project started successfully
"vite": "^4.0.4",
"vite-aliases": "0.9.2"
@redyouzi unfortunately i cannot replicate the issue above and it doesnt seem that i can get more information from the reporter. Would you be able to provide more info? If you try to run the example
of vite-aliases, does that work for you?
Any more Information on these Bugs would be great, as i cannot replicate them. Due to the Issues being stale, i have now closed them till there is more Information for me available that i can work with.
I came across this issue as well and after some trial and error the problem ended up being this line in my tsconfig.json
and the problem was fixed after commenting it out:
resolve: {
alias: {
'@': path.resolve('./src'),
},
},