Skip to content

Commit 97d200c

Browse files
authored
fix(vue): skip url query request (fixes #10863) (#10920)
fixes #10863
1 parent fc007df commit 97d200c

File tree

8 files changed

+28
-2
lines changed

8 files changed

+28
-2
lines changed

packages/plugin-vue/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
207207
transform(code, id, opt) {
208208
const ssr = opt?.ssr === true
209209
const { filename, query } = parseVueRequest(id)
210-
if (query.raw) {
210+
if (query.raw || query.url) {
211211
return
212212
}
213213
if (!filter(filename) && !query.vue) {

packages/plugin-vue/src/utils/query.ts

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface VueQuery {
55
index?: number
66
lang?: string
77
raw?: boolean
8+
url?: boolean
89
scoped?: boolean
910
}
1011

@@ -23,6 +24,9 @@ export function parseVueRequest(id: string): {
2324
if (query.raw != null) {
2425
query.raw = true
2526
}
27+
if (query.url != null) {
28+
query.url = true
29+
}
2630
if (query.scoped != null) {
2731
query.scoped = true
2832
}

playground/vue/Main.vue

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<ReactivityTransform :foo="time" />
2323
<SetupImportTemplate />
2424
<WorkerTest />
25+
<Url />
2526
</template>
2627

2728
<script setup lang="ts">
@@ -40,6 +41,7 @@ import ReactivityTransform from './ReactivityTransform.vue'
4041
import SetupImportTemplate from './setup-import-template/SetupImportTemplate.vue'
4142
import WorkerTest from './worker.vue'
4243
import { ref } from 'vue'
44+
import Url from './Url.vue'
4345
4446
const time = ref('loading...')
4547

playground/vue/Null.vue

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template>null</template>

playground/vue/Url.vue

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script setup>
2+
import url from './Null.vue?url'
3+
</script>
4+
5+
<template>
6+
<h2>import with ?url</h2>
7+
<div>
8+
URL of Null.vue: <span class="import-with-url-query">{{ url }}</span>
9+
</div>
10+
</template>

playground/vue/__tests__/vue.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,11 @@ describe('vue worker', () => {
263263
expect(await page.textContent('.vue-worker')).toMatch('worker load!')
264264
})
265265
})
266+
267+
describe('import with ?url', () => {
268+
test('should work', async () => {
269+
expect(await page.textContent('.import-with-url-query')).toMatch(
270+
isBuild ? /^data:/ : '/Null.vue'
271+
)
272+
})
273+
})

playground/vue/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// esbuild transpile should ignore this
44
"target": "ES5"
55
},
6-
"include": ["src"]
6+
"include": ["."]
77
}

playground/vue/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

0 commit comments

Comments
 (0)