Skip to content

Commit

Permalink
fix: merge custom queries rather than appending (vuejs#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored and freddy38510 committed Nov 17, 2022
1 parent 0debd36 commit dccffeb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Expand Up @@ -75,11 +75,12 @@ export default function loader(
sourceMap,
rootContext,
resourcePath,
resourceQuery = '',
resourceQuery: _resourceQuery = '',
} = loaderContext

const rawQuery = resourceQuery.slice(1)
const rawQuery = _resourceQuery.slice(1)
const incomingQuery = qs.parse(rawQuery)
const resourceQuery = rawQuery ? `&${rawQuery}` : ''
const options = (loaderUtils.getOptions(loaderContext) ||
{}) as VueLoaderOptions

Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/custom-query.vue
@@ -0,0 +1,5 @@
<script lang="ts">
import BasicComponent from './basic.vue?custom=true'
export default BasicComponent
</script>
8 changes: 8 additions & 0 deletions test/script.spec.ts
Expand Up @@ -11,3 +11,11 @@ test('named exports', async () => {
test('experimental <script setup>', async () => {
await mockBundleAndRun({ entry: 'ScriptSetup.vue' })
})

test('should handle custom resource query', async () => {
const { exports } = await mockBundleAndRun({
entry: 'custom-query.vue',
})

expect(exports.default.data().msg).toBe('Hello from Component A!')
})

0 comments on commit dccffeb

Please sign in to comment.