Skip to content

Commit

Permalink
test: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Oct 12, 2023
1 parent 56c6726 commit 05c20d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion playground/js-sourcemap/__tests__/js-sourcemap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (!isBuild) {
`)
})

test('js with existing inline sourcemap', async () => {
test('js with inline sourcemap injected by a plugin', async () => {
const res = await page.request.get(
new URL('./foo-with-sourcemap.js', page.url()).href,
)
Expand Down
8 changes: 5 additions & 3 deletions playground/js-sourcemap/foo-with-sourcemap-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type { Plugin } from 'vite'

export const commentSourceMap =
'//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHIn0='
export const commentSourceMap = [
'// default boundary sourcemap with magic-string',
'//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHIn0=',
].join('\n')

export default function transformFooWithInlineSourceMap(): Plugin {
return {
name: 'transform-foo-with-inline-sourcemap',
transform(code, id) {
if (id.includes('foo-with-sourcemap.js')) {
return `${code}\n${commentSourceMap}`
return `${code}${commentSourceMap}`
}
},
}
Expand Down
2 changes: 0 additions & 2 deletions playground/js-sourcemap/foo-with-sourcemap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export const foo = 'foo'

// default boundary sourcemap with magic-string

0 comments on commit 05c20d9

Please sign in to comment.