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(sourcemap): tolerate virtual modules in sources array #5587

Merged
merged 4 commits into from
Nov 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add comment
  • Loading branch information
aleclarson committed Nov 8, 2021
commit 9869337169c764b1c5193b2130c23b7be95b1b38
4 changes: 4 additions & 0 deletions packages/vite/src/node/server/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const debug = createDebugger('vite:sourcemap', {
onlyWhenFocused: true
})

// Virtual modules should be prefixed with a null byte to avoid a
// false positive "missing source" warning. We also check for colons,
// because the optimizer emits sourcemaps with sources like "dep:react"
// due to namespacing for special handling in esbuildDepPlugin.
const virtualSourceRE = /:|\0/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this check to be more targeted. What about

Suggested change
const virtualSourceRE = /:|\0/
const virtualSourceRE = /^(\0|dep:)/


interface SourceMapLike {
Expand Down