Skip to content

Commit a0d043c

Browse files
committed
test: add test
1 parent 0b65d21 commit a0d043c

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

packages/plugin-vue/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ export async function transformMain(
200200
// if the template is inlined into the main module (indicated by the presence
201201
// of templateMap), we need to concatenate the two source maps.
202202
const from = scriptMap ?? {
203+
file: filename,
204+
sourceRoot: '',
203205
version: 3,
204206
sources: [],
207+
sourcesContent: [],
205208
names: [],
206209
mappings: '',
207210
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script setup></script>
2+
<template>
3+
<p>&lt;empty-script&gt;</p>
4+
</template>

playground/vue-sourcemap/__tests__/__snapshots__/vue-sourcemap.spec.ts.snap

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ exports[`serve:vue-sourcemap > css scoped > serve-css-scoped 1`] = `
144144
}
145145
`;
146146

147+
exports[`serve:vue-sourcemap > empty script > serve-empty-script 1`] = `
148+
{
149+
"ignoreList": [],
150+
"mappings": ";;;;wBAEE,oBAA2B,WAAxB,gBAAoB",
151+
"sources": [
152+
"EmptyScript.vue",
153+
],
154+
"sourcesContent": [
155+
"<script setup></script>
156+
<template>
157+
<p>&lt;empty-script&gt;</p>
158+
</template>
159+
",
160+
],
161+
"version": 3,
162+
}
163+
`;
164+
147165
exports[`serve:vue-sourcemap > js > serve-js 1`] = `
148166
{
149167
"ignoreList": [],
@@ -194,7 +212,8 @@ exports[`serve:vue-sourcemap > less with additionalData > serve-less-with-additi
194212

195213
exports[`serve:vue-sourcemap > no script > serve-no-script 1`] = `
196214
{
197-
"mappings": ";;;wBACE,oBAAwB,WAArB,aAAiB",
215+
"ignoreList": [],
216+
"mappings": ";;;;wBACE,oBAAwB,WAArB,aAAiB",
198217
"sources": [
199218
"NoScript.vue",
200219
],

playground/vue-sourcemap/__tests__/vue-sourcemap.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => {
100100
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot('serve-no-script')
101101
})
102102

103+
test('empty script', async () => {
104+
const res = await page.request.get(
105+
new URL('./EmptyScript.vue', page.url()).href,
106+
)
107+
const js = await res.text()
108+
const map = extractSourcemap(js)
109+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot(
110+
'serve-empty-script',
111+
)
112+
})
113+
103114
test('no template', async () => {
104115
const res = await page.request.get(
105116
new URL('./NoTemplate.vue', page.url()).href,

0 commit comments

Comments
 (0)