Skip to content
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

chore(deps): update dependency convert-source-map to v2 #10548

Merged
merged 2 commits into from Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
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
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
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
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
46 changes: 14 additions & 32 deletions pnpm-lock.yaml

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