unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.74k stars 349 forks source link

pnpm workspace is not supported #607

Open lucasalbuquerque opened 1 year ago

lucasalbuquerque commented 1 year ago

Describe the bug

Addition a relative paths to "dirs" array not working when it's outside the project dir.

My current workspace structure:

apps/
    ─ appname
         ─ src
         ...
         vite.config.ts
packages/
    ─ components
         **.vue

vite.config.ts

Components({
      dirs: ['../../packages/components', 'src/components'],
      dts: 'src/components.d.ts',
      directoryAsNamespace: true,
      resolvers: [
        IconsResolver({
          prefix: 'icon',
          customCollections: ['girassol', 'illustration'],
        }),
      ],
}),

When I create a new component inside the '../../packages/components' directory it is not being mapped in my src/components.d.ts file.

Reproduction

Above - it contained code

System Info

System:
    OS: macOS 12.6.1
    CPU: (8) arm64 Apple M2
    Memory: 70.03 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.0.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 110.0.5481.177
    Safari: 15.6.1

Used Package Manager

pnpm

Validations

productdevbook commented 1 year ago

same problem

loocus commented 1 year ago

Refer to the source code implementation. When initializing Context, dirs and root (process. cwd()) will be merged. If you use relative paths, the merged paths will be incorrect. Therefore, you need to change ../../packages/components to packages/components, hoping to be helpful for your problem https://github.com/antfu/unplugin-vue-components/blob/main/src/core/options.ts#L28 https://github.com/antfu/unplugin-vue-components/blob/main/src/core/context.ts#L37