Skip to content

Commit dccffeb

Browse files
danielroefreddy38510
authored andcommitted
fix: merge custom queries rather than appending (vuejs#1911)
1 parent 0debd36 commit dccffeb

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ export default function loader(
7575
sourceMap,
7676
rootContext,
7777
resourcePath,
78-
resourceQuery = '',
78+
resourceQuery: _resourceQuery = '',
7979
} = loaderContext
8080

81-
const rawQuery = resourceQuery.slice(1)
81+
const rawQuery = _resourceQuery.slice(1)
8282
const incomingQuery = qs.parse(rawQuery)
83+
const resourceQuery = rawQuery ? `&${rawQuery}` : ''
8384
const options = (loaderUtils.getOptions(loaderContext) ||
8485
{}) as VueLoaderOptions
8586

test/fixtures/custom-query.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
import BasicComponent from './basic.vue?custom=true'
3+
4+
export default BasicComponent
5+
</script>

test/script.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ test('named exports', async () => {
1111
test('experimental <script setup>', async () => {
1212
await mockBundleAndRun({ entry: 'ScriptSetup.vue' })
1313
})
14+
15+
test('should handle custom resource query', async () => {
16+
const { exports } = await mockBundleAndRun({
17+
entry: 'custom-query.vue',
18+
})
19+
20+
expect(exports.default.data().msg).toBe('Hello from Component A!')
21+
})

0 commit comments

Comments
 (0)
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