问题
I have been trying out the Source Maps feature in Chrome and have found that it does not support having a single javascript resource attached to a script tag that contains multiple modules concatenated together along with a //@sourceMappingURL
comment separating each one.
The first mapping is hooked up and I see the modules source associated in the debugger but all the others are ignored.
I would expect that it would be a comment requirement to do this when multiple modules are minified and concatenated together
Is scenario supported?
回答1:
Chrome DevTools does not support multiple sourceMappingURLs defined in a single file. (Pavel's answer from 2012 is incorrect unfortunately.) Relatedly, Chrome also does not support multiple sourceURLs in a single file.
The linked spec chapter refers to a sections array, but that's defined within a single parent map that addresses the entire file.
Therefore, if your code looks like this:
// ... code()
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3V…
},{"./bufferClone":99}],122:[function(require,module,exports){
// ... code()
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kd…
}
.. then you'll need to adjust your compilation pipeline so there is only a single map for your final bundled file.
回答2:
Yes, it is supported. You can provide source maps for parts of your script using "sections" field. See Index map: supporting post processing section of the spec.
来源:https://stackoverflow.com/questions/12568403/does-chrome-support-multiple-modules-sourcemappingurls-on-a-single-javascript-ur