From 8dc65288cd47b72fbf3fd7c804b1405591f66a34 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 07:30:53 +0100 Subject: [PATCH] chore(deps): update dependency convert-source-map to v2 (#10548) Co-authored-by: sapphi-red --- package.json | 2 +- packages/vite/package.json | 2 +- .../vite/src/node/server/transformRequest.ts | 14 ++++++++++++- playground/package.json | 2 +- pnpm-lock.yaml | 20 +++++++++++-------- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 00b41c75c62b20..068c616d19a64c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/vite/package.json b/packages/vite/package.json index ca373a380414e6..714569e8d07bc9 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -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", diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 79e94cd04c15c0..f10cfde5ac3b87 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -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) @@ -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', + ) + } +} diff --git a/playground/package.json b/playground/package.json index c3e5f1441ce081..72412c12552a30 100644 --- a/playground/package.json +++ b/playground/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 088fff8308ff88..a74364fbbd2bc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,7 +22,7 @@ importers: '@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 @@ -79,7 +79,7 @@ importers: '@rollup/plugin-typescript': 10.0.1_w32d2yt4tg6e3zn5worlea7ffu '@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 @@ -183,7 +183,7 @@ importers: 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 @@ -250,7 +250,7 @@ importers: 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 @@ -290,13 +290,13 @@ importers: playground: specifiers: - 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 sirv: ^2.0.2 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 @@ -2191,8 +2191,8 @@ packages: resolution: {integrity: sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==} dev: true - /@types/convert-source-map/1.5.2: - resolution: {integrity: sha512-tHs++ZeXer40kCF2JpE51Hg7t4HPa18B1b1Dzy96S0eCw8QKECNMYMfwa1edK/x8yCN0r4e6ewvLcc5CsVGkdg==} + /@types/convert-source-map/2.0.0: + resolution: {integrity: sha512-QUm4YOC/ENo0VjPVl2o8HGyTbHHQGDOw8PCg3rXBucYHKyZN/XjXRbPFAV1tB2FvM0/wyFoDct4cTIctzKrQFg==} dev: true /@types/cross-spawn/6.0.2: @@ -3416,6 +3416,10 @@ packages: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} dev: true + /convert-source-map/2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + dev: true + /cookie-signature/1.0.6: resolution: {integrity: sha1-4wOogrNCzD7oylE6eZmXNNqzriw=}