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

fix: remove loaded input sourcemap (fixes #8411) #10705

Merged
merged 1 commit into from Oct 29, 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
4 changes: 4 additions & 0 deletions packages/vite/src/node/server/pluginContainer.ts
Expand Up @@ -472,6 +472,10 @@ export async function createPluginContainer(
this.filename = filename
this.originalCode = code
if (inMap) {
if (isDebugSourcemapCombineFocused) {
// @ts-expect-error inject name for debug purpose
inMap.name = '$inMap'
}
this.sourcemapChain.push(inMap)
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/server/transformRequest.ts
Expand Up @@ -7,6 +7,7 @@ import type { SourceDescription, SourceMap } from 'rollup'
import colors from 'picocolors'
import type { ViteDevServer } from '..'
import {
blankReplacer,
cleanUrl,
createDebugger,
ensureWatchedFile,
Expand Down Expand Up @@ -196,6 +197,8 @@ async function loadAndTransform(
convertSourceMap.fromSource(code) ||
convertSourceMap.fromMapFileSource(code, path.dirname(file))
)?.toObject()

code = code.replace(convertSourceMap.mapFileCommentRegex, blankReplacer)
} catch (e) {
logger.warn(`Failed to load source map for ${url}.`, {
timestamp: true
Expand Down
4 changes: 4 additions & 0 deletions playground/css-sourcemap/index.html
Expand Up @@ -26,6 +26,8 @@ <h1>CSS Sourcemap</h1>
<p class="imported-stylus">&lt;imported stylus&gt;</p>

<p class="imported-sugarss">&lt;imported sugarss&gt;</p>

<p class="input-map">&lt;input source-map&gt;</p>
</div>

<script type="module">
Expand All @@ -44,6 +46,8 @@ <h1>CSS Sourcemap</h1>
import './imported.styl'

import './imported.sss'

import './input-map.css'
</script>

<iframe src="virtual.html"></iframe>
4 changes: 4 additions & 0 deletions playground/css-sourcemap/input-map.css

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

7 changes: 7 additions & 0 deletions playground/css-sourcemap/input-map.css.map

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

3 changes: 3 additions & 0 deletions playground/css-sourcemap/input-map.src.css
@@ -0,0 +1,3 @@
.input-map {
color: blue;
}