I am attempting to use the devtool feature of webpack, I have set up my configuration like so:
{
devtool: 'eval-source-map'
}
This appears to work fine and I can see that my source code is being wrapped within eval() functions and that a base64 source map is appended to the end.
However my errors are not being mapped to the source (Chrome developer tools), instead I am getting errors like the following:
ReferenceError: _ is not defined
at eval (eval at <anonymous> (http://localhost:8080/build/abc.js:78:2), <anonymous>:125:21)
Where abc.js is the name of my built and concatenated file. Clicking the error to the view the source just takes me to the eval function like so:
eval("var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {\n /** @type {angular.Module} */\n return angular.module('utils', []);\n}.call(exports, __webpack_require__, exports, module)), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n\n// Load exports\n__webpack_require__(6);\n//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4vbW9kdWxlcy91dGlscy9zcmMvbW9kdWxlLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJrQ0FBQTtBQUNBLGFBQWEsZUFBZTtBQUM1QjtBQUNBLENBQUM7O0FBRUQ7QUFDQSIsInNvdXJjZXNDb250ZW50IjpbImRlZmluZShmdW5jdGlvbigpIHtcbiAgLyoqIEB0eXBlIHthbmd1bGFyLk1vZHVsZX0gKi9cbiAgcmV0dXJuIGFuZ3VsYXIubW9kdWxlKCd1dGlscycsIFtdKTtcbn0pO1xuXG4vLyBMb2FkIGV4cG9ydHNcbnJlcXVpcmUoJy4vZXhwb3J0cy9jb3JlJyk7XG4iXSwic291cmNlUm9vdCI6IndlYnBhY2stbW9kdWxlOi8vIn0=");
If I decode the base64 I can see that the source maps it is generating appear to be valid:
{
"version":3,
"sources":[
"./modules/utils/src/module.js"
],
"names":[
],
"mappings":"kCAAA;AACA,aAAa,eAAe;AAC5B;AACA,CAAC;;AAED;AACA",
"sourcesContent":[
"define(function() {\n /** @type {angular.Module} */\n return angular.module('utils', []);\n});\n\n// Load exports\nrequire('./exports/core');\n"
],
"sourceRoot":"webpack-module://"
}
Does anyone know why these source maps don't appear to be working? The webpack documentation is still a bit ambiguous in areas.
Please not I am only using eval-source-map in development and a seperate map file is generated for production (which also does not work).
This type of 'devtool' helped me
devtool: 'eval'