Skip to content

Commit b0400f3

Browse files
authored
fix(vue): import with query (#592)
1 parent 5f43900 commit b0400f3

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

packages/plugin-vue/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import type {
99
} from 'vue/compiler-sfc'
1010
import type * as _compiler from 'vue/compiler-sfc'
1111
import { computed, shallowRef } from 'vue'
12-
import { exactRegex } from '@rolldown/pluginutils'
12+
import {
13+
exactRegex,
14+
makeIdFiltersToMatchWithQuery,
15+
} from '@rolldown/pluginutils'
1316
import { version } from '../package.json'
1417
import { resolveCompiler } from './compiler'
1518
import { parseVueRequest } from './utils/query'
@@ -358,7 +361,10 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
358361
optionsHookIsCalled = true
359362
;(plugin.transform as TransformObjectHook).filter = {
360363
id: {
361-
include: [...ensureArray(include.value), /[?&]vue\b/],
364+
include: [
365+
...makeIdFiltersToMatchWithQuery(ensureArray(include.value)),
366+
/[?&]vue\b/,
367+
],
362368
exclude: exclude.value,
363369
},
364370
}

playground/vue/Main.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<HmrCircularReference name="test" />
1212
<TypeProps msg="msg" bar="bar" :id="123" />
1313
<TypePropsTsx msg="msg" bar="bar" />
14+
<WithQuery />
1415
<Syntax />
1516
<PreProcessors />
1617
<PreProcessorsHmr />
@@ -44,6 +45,7 @@
4445
import { version, defineAsyncComponent } from 'vue'
4546
import Hmr from './Hmr.vue'
4647
import HmrTsx from './HmrTsx.vue'
48+
import WithQuery from './WithQuery.vue?with-query'
4749
import Syntax from './Syntax.vue'
4850
import PreProcessors from './PreProcessors.vue'
4951
import PreProcessorsHmr from './PreProcessorsHmr.vue'

playground/vue/WithQuery.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<h2>Imported with query</h2>
3+
<p class="imported-with-query">{{ foo }}</p>
4+
</template>
5+
6+
<script setup>
7+
const foo = 'ok'
8+
</script>

playground/vue/__tests__/vue.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ test('should update', async () => {
2222
expect(await page.textContent('.hmr-inc')).toMatch('count is 1')
2323
})
2424

25+
test('import with query should work', async () => {
26+
expect(await page.textContent('.imported-with-query')).toMatch('ok')
27+
})
28+
2529
test('template/script latest syntax support', async () => {
2630
expect(await page.textContent('.syntax')).toBe('baz')
2731
})

0 commit comments

Comments
 (0)