Skip to content

Commit

Permalink
chore(deps): update dependency convert-source-map to v2 (#10548)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <green@sapphi.red>
  • Loading branch information
renovate[bot] and sapphi-red committed Dec 14, 2022
1 parent fd36698 commit 8dc6528
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@rollup/plugin-typescript": "^10.0.1",
"@types/babel__core": "^7.1.20",
"@types/babel__standalone": "^7.1.4",
"@types/convert-source-map": "^1.5.2",
"@types/convert-source-map": "^2.0.0",
"@types/cross-spawn": "^6.0.2",
"@types/debug": "^4.1.7",
"@types/estree": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"chokidar": "^3.5.3",
"connect": "^3.7.0",
"connect-history-api-fallback": "^2.0.0",
"convert-source-map": "^1.9.0",
"convert-source-map": "^2.0.0",
"cors": "^2.8.5",
"cross-spawn": "^7.0.3",
"debug": "^4.3.4",
Expand Down
14 changes: 13 additions & 1 deletion packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ async function loadAndTransform(
try {
map = (
convertSourceMap.fromSource(code) ||
convertSourceMap.fromMapFileSource(code, path.dirname(file))
(await convertSourceMap.fromMapFileSource(
code,
createConvertSourceMapReadMap(file),
))
)?.toObject()

code = code.replace(convertSourceMap.mapFileCommentRegex, blankReplacer)
Expand Down Expand Up @@ -280,3 +283,12 @@ async function loadAndTransform(

return result
}

function createConvertSourceMapReadMap(originalFileName: string) {
return (filename: string) => {
return fs.readFile(
path.resolve(path.dirname(originalFileName), filename),
'utf-8',
)
}
}
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"version": "1.0.0",
"devDependencies": {
"convert-source-map": "^1.9.0",
"convert-source-map": "^2.0.0",
"css-color-names": "^1.0.1",
"kill-port": "^1.6.1",
"node-fetch": "^3.3.0",
Expand Down
20 changes: 12 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8dc6528

Please sign in to comment.