Skip to content

fix: sourcemap broken #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion packages/core/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import MagicString from 'magic-string'

export function supportScriptName(code: string, id: string) {
let s: MagicString | undefined
const FILENAME_RE = /.*\/(\S*)/
const str = () => s || (s = new MagicString(code))
const { descriptor } = parse(code)
if (!descriptor.script && descriptor.scriptSetup) {
Expand All @@ -20,8 +21,15 @@ export default defineComponent({
</script>\n`,
)
}

const map = str().generateMap({ hires: true })
const filename = FILENAME_RE.exec(id)![1]

map.file = filename
map.sources = [filename]

return {
map: str().generateMap(),
map,
code: str().toString(),
}
} else {
Expand Down