Skip to content

Commit 3797e4d

Browse files
fix: sourcemap generating when previous loader pass sourcemap as string (#905)
1 parent cc81af1 commit 3797e4d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ export default function loader(content, map, meta) {
4444
if (sourceMap) {
4545
if (map) {
4646
// Some loader emit source map as string
47+
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
4748
if (typeof map === 'string') {
48-
map = JSON.stringify(map);
49+
map = JSON.parse(map.replace(/^\)]}'[^\n]*\n/, ''));
4950
}
5051

5152
// Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)

0 commit comments

Comments
 (0)