Does Chrome support multiple modules/sourceMappingURLs on a single javascript url

谁说我不能喝 提交于 2019-12-10 10:05:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!