From 7b9b201d6855280c6cb4e765794bbdec94213193 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 19 Feb 2025 13:19:38 +0800 Subject: [PATCH 1/6] chore: update ci --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e031e46..53fc27dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,13 +15,13 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - name: Set node uses: actions/setup-node@v4 with: node-version: lts/* - - run: corepack enable - - name: Setup run: npm i -g @antfu/ni @@ -43,13 +43,13 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - name: Set node version to ${{ matrix.node }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - run: corepack enable - - name: Setup run: npm i -g @antfu/ni From 8fa96558b6b346a905fd2a7634402a8c2f934858 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 19 Feb 2025 13:23:56 +0800 Subject: [PATCH 2/6] fix: disable `expandDirectories` in tinyglobby --- src/core/fs/glob.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/fs/glob.ts b/src/core/fs/glob.ts index eb917792..912d326b 100644 --- a/src/core/fs/glob.ts +++ b/src/core/fs/glob.ts @@ -12,6 +12,7 @@ export function searchComponents(ctx: Context) { onlyFiles: true, cwd: root, absolute: true, + expandDirectories: false, }) if (!files.length && !ctx.options.resolvers?.length) From c69425ee044b716e6003eaa5bf3feae5619276be Mon Sep 17 00:00:00 2001 From: wChenonly <37658262+wChenonly@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:26:30 +0800 Subject: [PATCH 3/6] fix: disable biome detection in generated components.d.ts (#792) --- src/core/declaration.ts | 1 + test/__snapshots__/dts.test.ts.snap | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/core/declaration.ts b/src/core/declaration.ts index 2c4b633d..99a5945e 100644 --- a/src/core/declaration.ts +++ b/src/core/declaration.ts @@ -118,6 +118,7 @@ export function getDeclaration(ctx: Context, filepath: string, originalImports?: // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ diff --git a/test/__snapshots__/dts.test.ts.snap b/test/__snapshots__/dts.test.ts.snap index 7dabf7c9..75752379 100644 --- a/test/__snapshots__/dts.test.ts.snap +++ b/test/__snapshots__/dts.test.ts.snap @@ -5,6 +5,7 @@ exports[`dts > components only 1`] = ` // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ @@ -23,6 +24,7 @@ exports[`dts > directive only 1`] = ` // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ @@ -39,6 +41,7 @@ exports[`dts > getDeclaration 1`] = ` // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ @@ -97,6 +100,7 @@ exports[`dts > vue 2.7 components only 1`] = ` // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ @@ -115,6 +119,7 @@ exports[`dts > writeDeclaration - keep unused 1`] = ` // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ @@ -139,6 +144,7 @@ exports[`dts > writeDeclaration 1`] = ` // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable export {} /* prettier-ignore */ From 6656ec52eab6f64525cc9ea48b1980405f0b07bc Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 19 Feb 2025 13:54:50 +0800 Subject: [PATCH 4/6] fix: fix how globs resolves, excludes nested `node_modules` folder by default (#826) --- src/core/options.ts | 39 ++++++++++++++++++++++++++++++--------- src/types.ts | 3 ++- test/search.test.ts | 12 ++++++++++-- vitest.config.ts | 10 ++++++---- 4 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/core/options.ts b/src/core/options.ts index 2c3939dc..fa4b1ddb 100644 --- a/src/core/options.ts +++ b/src/core/options.ts @@ -4,7 +4,7 @@ import { slash, toArray } from '@antfu/utils' import { getPackageInfoSync, isPackageExists } from 'local-pkg' import { detectTypeImports } from './type-imports/detect' -export const defaultOptions: Omit, 'include' | 'exclude' | 'excludeNames' | 'transformer' | 'globs' | 'directives' | 'types' | 'version'> = { +export const defaultOptions: Omit, 'include' | 'exclude' | 'excludeNames' | 'transformer' | 'globs' | 'globsExclude' | 'directives' | 'types' | 'version'> = { dirs: 'src/components', extensions: 'vue', deep: true, @@ -17,7 +17,6 @@ export const defaultOptions: Omit, 'include' | 'exclude' | 'ex transformerUserResolveFunctions: true, resolvers: [], - globsExclude: [], importPathTransform: v => v, @@ -30,7 +29,7 @@ function normalizeResolvers(resolvers: (ComponentResolver | ComponentResolver[]) function resolveGlobsExclude(root: string, glob: string) { const excludeReg = /^!/ - return `${excludeReg.test(glob) ? '!' : ''}${resolve(root, glob.replace(excludeReg, ''))}` + return slash(`${excludeReg.test(glob) ? '!' : ''}${resolve(root, glob.replace(excludeReg, ''))}`) } export function resolveOptions(options: Options, root: string): ResolvedOptions { @@ -39,7 +38,8 @@ export function resolveOptions(options: Options, root: string): ResolvedOptions resolved.extensions = toArray(resolved.extensions) if (resolved.globs) { - resolved.globs = toArray(resolved.globs).map((glob: string) => slash(resolveGlobsExclude(root, glob))) + resolved.globs = toArray(resolved.globs) + .map(glob => resolveGlobsExclude(root, glob)) resolved.resolvedDirs = [] } else { @@ -48,17 +48,38 @@ export function resolveOptions(options: Options, root: string): ResolvedOptions : `{${resolved.extensions.join(',')}}` resolved.dirs = toArray(resolved.dirs) - resolved.resolvedDirs = resolved.dirs.map(i => slash(resolveGlobsExclude(root, i))) - resolved.globs = resolved.resolvedDirs.map(i => resolved.deep - ? slash(join(i, `**/*.${extsGlob}`)) - : slash(join(i, `*.${extsGlob}`)), - ) + const globs = resolved.dirs.map(i => resolveGlobsExclude(root, i)) + + resolved.resolvedDirs = globs.filter(i => !i.startsWith('!')) + resolved.globs = globs.map((i) => { + let prefix = '' + if (i.startsWith('!')) { + prefix = '!' + i = i.slice(1) + } + return resolved.deep + ? prefix + slash(join(i, `**/*.${extsGlob}`)) + : prefix + slash(join(i, `*.${extsGlob}`)) + }) if (!resolved.extensions.length) throw new Error('[unplugin-vue-components] `extensions` option is required to search for components') } + if (!resolved.globsExclude) + resolved.globsExclude = [`**/node_modules/**`] + resolved.globsExclude = toArray(resolved.globsExclude || []) + .map(i => resolveGlobsExclude(root, i)) + + // Move negated globs to globsExclude + resolved.globs = resolved.globs.filter((i) => { + if (!i.startsWith('!')) + return true + resolved.globsExclude.push(i.slice(1)) + return false + }) + resolved.dts = !resolved.dts ? false : resolve( diff --git a/src/types.ts b/src/types.ts index f16133a7..a7010bb4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -98,7 +98,7 @@ export interface Options { /** * Negated glob patterns to exclude files from being detected as components. * - * @default [] + * @default ['/**\/node_modules/**'] */ globsExclude?: string | string[] @@ -209,6 +209,7 @@ export type ResolvedOptions = Omit< dirs: string[] resolvedDirs: string[] globs: string[] + globsExclude: string[] dts: string | false root: string } diff --git a/test/search.test.ts b/test/search.test.ts index e48bec4d..3277da05 100644 --- a/test/search.test.ts +++ b/test/search.test.ts @@ -1,5 +1,5 @@ import { relative, resolve } from 'pathe' -import { describe, expect, it } from 'vitest' +import { describe, expect, it, onTestFailed } from 'vitest' import { Context } from '../src/core/context' const root = resolve(__dirname, '../examples/vite-vue3') @@ -64,10 +64,18 @@ describe('search', () => { '!src/components/book', ], }) + + onTestFailed(() => { + console.error('resolved options') + console.error(ctx.options) + }) + ctx.setRoot(root) ctx.searchGlob() - expect(cleanup(ctx.componentNameMap).map(i => i.as)).not.toEqual(expect.arrayContaining(['Book'])) + expect(cleanup(ctx.componentNameMap).map(i => i.as)) + .not + .contain('Book') }) it('should excludeNames', () => { diff --git a/vitest.config.ts b/vitest.config.ts index 637aa94f..93c91c41 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -2,10 +2,12 @@ import { defineConfig } from 'vite' export default defineConfig({ test: { - deps: { - inline: [ - '@babel/types', - ], + server: { + deps: { + inline: [ + '@babel/types', + ], + }, }, }, }) From 30bd3e4376d69492a00d295b12254051ee8136e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=80=9D=E6=B0=B4=E7=BB=8F=E5=B9=B4?= <73976915+entireyu@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:56:12 +0800 Subject: [PATCH 5/6] fix(tdesign): fix a series of components related to typography (#813) --- src/core/resolvers/tdesign.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/resolvers/tdesign.ts b/src/core/resolvers/tdesign.ts index 4ebf3e4d..283d7368 100644 --- a/src/core/resolvers/tdesign.ts +++ b/src/core/resolvers/tdesign.ts @@ -46,6 +46,13 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component } } + if (name.startsWith('TTypography') || name.startsWith('Typography')) { + return { + name: name.slice(name.startsWith('TTypography') ? 11 : 10), + from: `tdesign-${library}${importFrom}`, + } + } + if (name.match(/^T[A-Z]/) || pluginList.includes(name)) { const importName = name.match(/^T[A-Z]/) ? name.slice(1) : name From 2c63265c6ab8ada11a01e5d5607316f3771b81aa Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 19 Feb 2025 13:58:37 +0800 Subject: [PATCH 6/6] chore: release v28.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 19c0076b..f3022ea4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unplugin-vue-components", "type": "module", - "version": "28.3.0", + "version": "28.4.0", "packageManager": "pnpm@10.4.0", "description": "Components auto importing for Vue", "author": "antfu ", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy