Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue): skip url query request (fixes #10863) #10920

Merged
merged 1 commit into from Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/index.ts
Expand Up @@ -207,7 +207,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
transform(code, id, opt) {
const ssr = opt?.ssr === true
const { filename, query } = parseVueRequest(id)
if (query.raw) {
if (query.raw || query.url) {
return
}
if (!filter(filename) && !query.vue) {
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-vue/src/utils/query.ts
Expand Up @@ -5,6 +5,7 @@ export interface VueQuery {
index?: number
lang?: string
raw?: boolean
url?: boolean
scoped?: boolean
}

Expand All @@ -23,6 +24,9 @@ export function parseVueRequest(id: string): {
if (query.raw != null) {
query.raw = true
}
if (query.url != null) {
query.url = true
}
if (query.scoped != null) {
query.scoped = true
}
Expand Down
2 changes: 2 additions & 0 deletions playground/vue/Main.vue
Expand Up @@ -22,6 +22,7 @@
<ReactivityTransform :foo="time" />
<SetupImportTemplate />
<WorkerTest />
<Url />
</template>

<script setup lang="ts">
Expand All @@ -40,6 +41,7 @@ import ReactivityTransform from './ReactivityTransform.vue'
import SetupImportTemplate from './setup-import-template/SetupImportTemplate.vue'
import WorkerTest from './worker.vue'
import { ref } from 'vue'
import Url from './Url.vue'

const time = ref('loading...')

Expand Down
1 change: 1 addition & 0 deletions playground/vue/Null.vue
@@ -0,0 +1 @@
<template>null</template>
10 changes: 10 additions & 0 deletions playground/vue/Url.vue
@@ -0,0 +1,10 @@
<script setup>
import url from './Null.vue?url'
</script>

<template>
<h2>import with ?url</h2>
<div>
URL of Null.vue: <span class="import-with-url-query">{{ url }}</span>
</div>
</template>
8 changes: 8 additions & 0 deletions playground/vue/__tests__/vue.spec.ts
Expand Up @@ -263,3 +263,11 @@ describe('vue worker', () => {
expect(await page.textContent('.vue-worker')).toMatch('worker load!')
})
})

describe('import with ?url', () => {
test('should work', async () => {
expect(await page.textContent('.import-with-url-query')).toMatch(
isBuild ? /^data:/ : '/Null.vue'
)
})
})
2 changes: 1 addition & 1 deletion playground/vue/tsconfig.json
Expand Up @@ -3,5 +3,5 @@
// esbuild transpile should ignore this
"target": "ES5"
},
"include": ["src"]
"include": ["."]
}
1 change: 1 addition & 0 deletions playground/vue/vite-env.d.ts
@@ -0,0 +1 @@
/// <reference types="vite/client" />