Skip to content

Commit

Permalink
feature: add support for vscode sourcemap file (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke authored Jul 20, 2024
1 parent b0b7974 commit 9da1ec9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'

export const loadSourceMap = async (url) => {
if (!url.startsWith('vscode-file://vscode-app')) {
throw new Error('unsupported source map url')
}
const fileUrl = `file://` + url.slice('vscode-file://vscode-app'.length)
const path = fileURLToPath(fileUrl)
const content = await readFile(path, 'utf8')
const data = JSON.parse(content)
return data
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const getModule = (protocol) => {
return import('../LoadSourceMapFromUrl/LoadSourceMapFromUrl.js')
case 'file':
return import('../LoadSourceMapFromFile/LoadSourceMapFromFile.js')
case 'vscode-file':
return import('../LoadSourceMapFromVscodeFile/LoadSourceMapFromVscodeFile.js')
case 'noop':
return {
loadSourceMap() {
Expand Down

0 comments on commit 9da1ec9

Please sign in to comment.