Skip to content

Commit 5ff929d

Browse files
committed
fix: ignore /@ prefixed importing
1 parent dda0610 commit 5ff929d

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/transforms/customComponent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export function CustomComponentTransformer(ctx: Context): Transform {
1212
},
1313
transform({ code, path }) {
1414
const filepath = ctx.normalizePath(path)
15-
const componentNames = Array.from(code.matchAll(/_resolveComponent\("(.*)"\)/g)).map(i => normalize(i[1]))
1615

16+
const componentNames = Array.from(code.matchAll(/_resolveComponent\("(.*)"\)/g)).map(i => normalize(i[1]))
1717
const entry = code.match(/export default ([a-zA-Z_$0-9]+);/)?.[1]
1818

1919
if (!entry) {

src/transforms/vueScript.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const debug = Debug('vite-plugin-components:transform:script')
1414
export function VueScriptTransformer(ctx: Context): Transform {
1515
return {
1616
test({ path, query }) {
17-
return path.endsWith('.vue') && !query.type
17+
return !path.startsWith('/@')
18+
&& path.endsWith('.vue')
19+
&& !query.type
1820
},
1921
transform({ code, path, isBuild }) {
2022
const filepath = ctx.normalizePath(ctx.relative(path))

src/transforms/vueScriptSetup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const debug = Debug('vite-plugin-components:transform:script-setup')
88
export function VueScriptSetupTransformer(ctx: Context): Transform {
99
return {
1010
test({ path, query }) {
11-
return path.endsWith('.vue')
11+
return !path.startsWith('/@')
12+
&& path.endsWith('.vue')
1213
&& query.type === 'script'
1314
&& (Boolean(query.setup) || query.setup === '')
1415
},

src/transforms/vueTemplate.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const debug = Debug('vite-plugin-components:transform:template')
1414
export function VueTemplateTransformer(ctx: Context): Transform {
1515
return {
1616
test({ path, query }) {
17-
return path.endsWith('.vue') && query.type === 'template'
17+
return !path.startsWith('/@')
18+
&& path.endsWith('.vue')
19+
&& query.type === 'template'
1820
},
1921
transform({ code, path }) {
2022
const filepath = ctx.normalizePath(path)

0 commit comments

Comments
 (0)