From 544478172c66eca657efeeb33c1b536e5390d1e6 Mon Sep 17 00:00:00 2001 From: Karshilov Date: Thu, 26 Jan 2023 18:14:43 +0800 Subject: [PATCH] fix: duplicated sourceMappingURL for worker bundles (fix #11601) (#11602) --- packages/vite/src/node/plugins/worker.ts | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 62432d0fd94579..d9f719b352437a 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -142,13 +142,7 @@ function emitSourcemapForWorkerEntry( const { map: sourcemap } = chunk if (sourcemap) { - if (config.build.sourcemap === 'inline') { - // Manually add the sourcemap to the code if configured for inline sourcemaps. - // TODO: Remove when https://github.com/rollup/rollup/issues/3913 is resolved - // Currently seems that it won't be resolved until Rollup 3 - const dataUrl = sourcemap.toUrl() - chunk.code += `//# sourceMappingURL=${dataUrl}` - } else if ( + if ( config.build.sourcemap === 'hidden' || config.build.sourcemap === true ) { @@ -159,20 +153,6 @@ function emitSourcemapForWorkerEntry( type: 'asset', source: data, }) - - // Emit the comment that tells the JS debugger where it can find the - // sourcemap file. - // 'hidden' causes the sourcemap file to be created but - // the comment in the file to be omitted. - if (config.build.sourcemap === true) { - // inline web workers need to use the full sourcemap path - // non-inline web workers can use a relative path - const sourceMapUrl = - query?.inline != null - ? mapFileName - : path.relative(config.build.assetsDir, mapFileName) - chunk.code += `//# sourceMappingURL=${sourceMapUrl}` - } } }