Subwaytime / vite-aliases

Alias auto generation for Vite
https://www.npmjs.com/package/vite-aliases
MIT License
210 stars 12 forks source link

[plugin vite:dep-scan] Cannot read properties of undefined (reading 'length') #51

Closed cool1809 closed 1 year ago

cool1809 commented 1 year ago

"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({
       ╵     
cool1809 commented 1 year ago

import { ViteAliases } from "vite-aliases";

// import { ViteAliases } from "../node_modules/vite-aliases";

cool1809 commented 1 year ago

Problems Persist.

Subwaytime commented 1 year ago

@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.

cool1809 commented 1 year ago

@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() }

Subwaytime commented 1 year ago

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.. :thinking:

humeng1010 commented 1 year ago

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"
Subwaytime commented 1 year ago

@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?

Subwaytime commented 1 year ago

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.

waruhachi commented 3 months ago

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'),
    },
},