grunt-contrib-concat icon indicating copy to clipboard operation
grunt-contrib-concat copied to clipboard

Unable to concatenate file with multiple sourcemaps

Open mattdsteele opened this issue 6 years ago • 3 comments

I've built a UMD bundle with Webpack 3.0.0, using devtool: '#source-map' as my source map generation option. It ends up producing a build with multiple //# sourceMappingUrl pragmas. For example:

/******/ ([
/* 0 */
/***/ (function(module, exports) {

module.exports = __WEBPACK_EXTERNAL_MODULE_0__;

/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
 /// code
};
//# sourceMappingURL=common.js.map

/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
 /// code
};
//# sourceMappingURL=predicates.js.map

/// etc, to end of file:
//# sourceMappingURL=build.js.map

Only the final build.js.map exists on disk. But this code finds the first sourceMappingUrl and attempts to read it, which results in errors such as:

Warning: Unable to read "C:\code\node_modules\sample\common.js.map" file (Error code: ENOENT). Use --force to continue.

I'm not familiar enough with the source map spec to know how to resolve this, but other tools (gulp, Chrome) seem to read this file fine.

mattdsteele avatar Jul 28 '17 18:07 mattdsteele