-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sourcemap): sourcemap is incorrect when sourcemap has `sources: […
…null]` (#14588) Co-authored-by: 翠 / green <[email protected]>
- Loading branch information
1 parent
fdbe04d
commit f8c6a34
Showing
9 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = 'foo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import MagicString from 'magic-string' | ||
import type { Plugin } from 'vite' | ||
|
||
export const transformZooWithSourcemapPlugin: () => Plugin = () => ({ | ||
name: 'sourcemap', | ||
transform(code, id) { | ||
if (id.includes('zoo.js')) { | ||
const ms = new MagicString(code) | ||
ms.append('// add comment') | ||
return { | ||
code: ms.toString(), | ||
// NOTE: MagicString without `filename` option generates | ||
// a sourcemap with `sources: ['']` or `sources: [null]` | ||
map: ms.generateMap({ hires: true }), | ||
} | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const zoo = 'zoo' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.