From 3797e4d79369b54cc8bb14a8a4e5f9d10b1b0137 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Wed, 6 Mar 2019 20:13:38 +0300 Subject: [PATCH] fix: sourcemap generating when previous loader pass sourcemap as string (#905) --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c5ab3f94..5b5a71ea 100644 --- a/src/index.js +++ b/src/index.js @@ -44,8 +44,9 @@ export default function loader(content, map, meta) { if (sourceMap) { if (map) { // Some loader emit source map as string + // Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON. if (typeof map === 'string') { - map = JSON.stringify(map); + map = JSON.parse(map.replace(/^\)]}'[^\n]*\n/, '')); } // Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)