Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/parse_ID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ export interface Query extends Record<string, any> {

export function parse_ID(id: string, root = '') {
const [file, rawQuery] = id.split('?', 2);
const filename = file.startsWith(root)
? file.replace(root, '').replace(/^\//, '')
: file;
const ext = extname(file).slice(1);
const query = (
rawQuery ? Object.fromEntries(new URLSearchParams(rawQuery)) : {}
) as Query;

return {
file: file.replace(root, ''),
file: filename,
isSfc: ext === 'vue',
isTsx: ext.startsWith('ts'),
isMdx: ext.startsWith('md'),
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/jsx/output.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default () => {
return <div __source="/test/fixtures/jsx/input.tsx:2:10">test</div>;
return <div __source="test/fixtures/jsx/input.tsx:2:10">test</div>;
};
4 changes: 2 additions & 2 deletions test/fixtures/md/output.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MD

<div __source="/test/fixtures/md/input.md:3:1">
<div __source="/test/fixtures/md/input.md:4:3">test</div>
<div __source="test/fixtures/md/input.md:3:1">
<div __source="test/fixtures/md/input.md:4:3">test</div>
</div>
4 changes: 2 additions & 2 deletions test/fixtures/mdx/output.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Mdx from 'mdx';

# MDX

<Mdx __source="/test/fixtures/mdx/input.mdx:5:1">
<div __source="/test/fixtures/mdx/input.mdx:6:3">test</div>
<Mdx __source="test/fixtures/mdx/input.mdx:5:1">
<div __source="test/fixtures/mdx/input.mdx:6:3">test</div>
</Mdx>
4 changes: 2 additions & 2 deletions test/fixtures/root/output.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template __source="/root/input.vue:1:1">
<div __source="/root/input.vue:2:3">test</div>
<template __source="root/input.vue:1:1">
<div __source="root/input.vue:2:3">test</div>
</template>
4 changes: 2 additions & 2 deletions test/fixtures/source-map/output.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template __source="/test/fixtures/source-map/input.vue:1:1">
<div __source="/test/fixtures/source-map/input.vue:2:3">test</div>
<template __source="test/fixtures/source-map/input.vue:1:1">
<div __source="test/fixtures/source-map/input.vue:2:3">test</div>
</template>
2 changes: 1 addition & 1 deletion test/fixtures/source-map/source-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"version": 3,
"sources": [""],
"names": [],
"mappings": "AAAA,4DAAS;AACT,yDAAM;AACN;"
"mappings": "AAAA,2DAAS;AACT,wDAAM;AACN;"
}
8 changes: 4 additions & 4 deletions test/fixtures/vue-setup-jsx/output.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script __source="/test/fixtures/vue-setup-jsx/input.vue:1:1" lang="tsx" setup>
<script __source="test/fixtures/vue-setup-jsx/input.vue:1:1" lang="tsx" setup>
const node = (
<div __source="/test/fixtures/vue-setup-jsx/input.vue:2:14">test</div>
<div __source="test/fixtures/vue-setup-jsx/input.vue:2:14">test</div>
);
</script>
<template __source="/test/fixtures/vue-setup-jsx/input.vue:4:1">
<div __source="/test/fixtures/vue-setup-jsx/input.vue:5:3">{{ node }}</div>
<template __source="test/fixtures/vue-setup-jsx/input.vue:4:1">
<div __source="test/fixtures/vue-setup-jsx/input.vue:5:3">{{ node }}</div>
</template>
6 changes: 2 additions & 4 deletions test/fixtures/vue-with-jsx/output.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script __source="/test/fixtures/vue-with-jsx/input.vue:1:1" lang="tsx">
<script __source="test/fixtures/vue-with-jsx/input.vue:1:1" lang="tsx">
export default {
render() {
return (
<div __source="/test/fixtures/vue-with-jsx/input.vue:4:12">test</div>
);
return <div __source="test/fixtures/vue-with-jsx/input.vue:4:12">test</div>;
},
};
</script>
4 changes: 2 additions & 2 deletions test/fixtures/vue/output.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template __source="/test/fixtures/vue/input.vue:1:1">
<div __source="/test/fixtures/vue/input.vue:2:3">test</div>
<template __source="test/fixtures/vue/input.vue:1:1">
<div __source="test/fixtures/vue/input.vue:2:3">test</div>
</template>