Skip to content

Commit

Permalink
fix: merge custom queries rather than appending (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Oct 28, 2022
1 parent 6a293df commit 9e4249a
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 9e4249a

Please sign in to comment.