Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
fix: update to use loader api that webpack 2+ exposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lewis committed Jul 9, 2017
1 parent a680f32 commit 7e686b9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 21 deletions.
49 changes: 48 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -8,7 +8,6 @@
"dist"
],
"dependencies": {
"convert-source-map": "^1.3.0",
"istanbul-lib-instrument": "^1.7.3",
"loader-utils": "^1.1.0"
},
Expand Down Expand Up @@ -49,7 +48,9 @@
"eslint-config-webpack": "^1.2.5",
"eslint-plugin-import": "^2.7.0",
"jest": "^20.0.4",
"jest-cli": "^20.0.4",
"lint-staged": "^3.6.1",
"memory-fs": "^0.4.1",
"nodemon": "^1.11.0",
"nsp": "^2.6.3",
"pre-commit": "^1.2.2",
Expand Down
21 changes: 6 additions & 15 deletions src/index.js
@@ -1,21 +1,12 @@
import { createInstrumenter } from 'istanbul-lib-instrument';
import loaderUtils from 'loader-utils';
import convert from 'convert-source-map';

export default function (source, sourceMap) {
let srcMap = sourceMap;
// use inline source map, if any
const inlineSourceMap = convert.fromSource(source);
if (!srcMap && inlineSourceMap) {
srcMap = inlineSourceMap.sourcemap;
}
export default function (source) {
const userOptions = loaderUtils.getOptions(this) || {};
userOptions.produceSourceMap = typeof userOptions.produceSourceMap === 'undefined' ? true : userOptions.produceSourceMap;
const instrumenter = createInstrumenter(userOptions);

const userOptions = loaderUtils.getOptions(this);
const instrumenter = createInstrumenter(
Object.assign({ produceSourceMap: this.srcMap }, userOptions),
);

return instrumenter.instrument(source, this.resourcePath, (error, source) => {
instrumenter.instrument(source, this.resourcePath, (error, source) => {
this.callback(error, source, instrumenter.lastSourceMap());
}, srcMap);
});
}
6 changes: 4 additions & 2 deletions test/__snapshots__/index.test.js.snap
@@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`disabled sourcemaps 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///webpack/bootstrap 1ae028e11f9e6449a2dd\\",\\"webpack:///./test/fixtures/basic.js\\"],\\"names\\":[],\\"mappings\\":\\";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;AC7DA,8BAA8B,uNAAuN,2GAA2G,KAAK,OAAO,gBAAgB,MAAM,kBAAkB,MAAM,OAAO,gBAAgB,MAAM,kBAAkB,MAAM,OAAO,gBAAgB,MAAM,mBAAmB,QAAQ,KAAK,2BAA2B,OAAO,gBAAgB,MAAM,iBAAiB,MAAM,OAAO,gBAAgB,MAAM,iBAAiB,QAAQ,MAAM,2BAA2B,OAAO,gBAAgB,MAAM,iBAAiB,MAAM,OAAO,gBAAgB,MAAM,iBAAiB,SAAS,aAAa,IAAI,kBAAkB,IAAI,YAAY,KAAK,4DAA4D,sCAAsC,EAAE,+CAA+C,uBAAuB,uBAAuB,oCAAoC,GAAG,sBAAsB,yBAAyB,MAAM,sBAAsB,sBAAsB,cAAc,MAAM,sBAAsB,sBAAsB,qB\\",\\"file\\":\\"main.js\\",\\"sourcesContent\\":[\\" \\\\t// The module cache\\\\n \\\\tvar installedModules = {};\\\\n\\\\n \\\\t// The require function\\\\n \\\\tfunction __webpack_require__(moduleId) {\\\\n\\\\n \\\\t\\\\t// Check if module is in cache\\\\n \\\\t\\\\tif(installedModules[moduleId]) {\\\\n \\\\t\\\\t\\\\treturn installedModules[moduleId].exports;\\\\n \\\\t\\\\t}\\\\n \\\\t\\\\t// Create a new module (and put it into the cache)\\\\n \\\\t\\\\tvar module = installedModules[moduleId] = {\\\\n \\\\t\\\\t\\\\ti: moduleId,\\\\n \\\\t\\\\t\\\\tl: false,\\\\n \\\\t\\\\t\\\\texports: {}\\\\n \\\\t\\\\t};\\\\n\\\\n \\\\t\\\\t// Execute the module function\\\\n \\\\t\\\\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\\\\n\\\\n \\\\t\\\\t// Flag the module as loaded\\\\n \\\\t\\\\tmodule.l = true;\\\\n\\\\n \\\\t\\\\t// Return the exports of the module\\\\n \\\\t\\\\treturn module.exports;\\\\n \\\\t}\\\\n\\\\n\\\\n \\\\t// expose the modules object (__webpack_modules__)\\\\n \\\\t__webpack_require__.m = modules;\\\\n\\\\n \\\\t// expose the module cache\\\\n \\\\t__webpack_require__.c = installedModules;\\\\n\\\\n \\\\t// define getter function for harmony exports\\\\n \\\\t__webpack_require__.d = function(exports, name, getter) {\\\\n \\\\t\\\\tif(!__webpack_require__.o(exports, name)) {\\\\n \\\\t\\\\t\\\\tObject.defineProperty(exports, name, {\\\\n \\\\t\\\\t\\\\t\\\\tconfigurable: false,\\\\n \\\\t\\\\t\\\\t\\\\tenumerable: true,\\\\n \\\\t\\\\t\\\\t\\\\tget: getter\\\\n \\\\t\\\\t\\\\t});\\\\n \\\\t\\\\t}\\\\n \\\\t};\\\\n\\\\n \\\\t// getDefaultExport function for compatibility with non-harmony modules\\\\n \\\\t__webpack_require__.n = function(module) {\\\\n \\\\t\\\\tvar getter = module && module.__esModule ?\\\\n \\\\t\\\\t\\\\tfunction getDefault() { return module['default']; } :\\\\n \\\\t\\\\t\\\\tfunction getModuleExports() { return module; };\\\\n \\\\t\\\\t__webpack_require__.d(getter, 'a', getter);\\\\n \\\\t\\\\treturn getter;\\\\n \\\\t};\\\\n\\\\n \\\\t// Object.prototype.hasOwnProperty.call\\\\n \\\\t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\\\\n\\\\n \\\\t// __webpack_public_path__\\\\n \\\\t__webpack_require__.p = \\\\\\"\\\\\\";\\\\n\\\\n \\\\t// Load entry module and return exports\\\\n \\\\treturn __webpack_require__(__webpack_require__.s = 0);\\\\n\\\\n\\\\n\\\\n// WEBPACK FOOTER //\\\\n// webpack/bootstrap 1ae028e11f9e6449a2dd\\",\\"var cov_2obfoewtj5=function(){var path=\\\\\\"/Users/mattlewis/Code/open-source/istanbul-instrumenter-loader/test/fixtures/basic.js\\\\\\",hash=\\\\\\"d160bda36fc8432c2ffbb2cefc3c20475fdbdbec\\\\\\",global=new Function('return this')(),gcv=\\\\\\"__coverage__\\\\\\",coverageData={path:\\\\\\"/Users/mattlewis/Code/open-source/istanbul-instrumenter-loader/test/fixtures/basic.js\\\\\\",statementMap:{\\\\\\"0\\\\\\":{start:{line:1,column:0},end:{line:11,column:2}},\\\\\\"1\\\\\\":{start:{line:4,column:4},end:{line:4,column:18}},\\\\\\"2\\\\\\":{start:{line:8,column:4},end:{line:8,column:23}}},fnMap:{\\\\\\"0\\\\\\":{name:\\\\\\"(anonymous_0)\\\\\\",decl:{start:{line:3,column:2},end:{line:3,column:3}},loc:{start:{line:3,column:8},end:{line:5,column:3}},line:3},\\\\\\"1\\\\\\":{name:\\\\\\"(anonymous_1)\\\\\\",decl:{start:{line:7,column:2},end:{line:7,column:3}},loc:{start:{line:7,column:8},end:{line:9,column:3}},line:7}},branchMap:{},s:{\\\\\\"0\\\\\\":0,\\\\\\"1\\\\\\":0,\\\\\\"2\\\\\\":0},f:{\\\\\\"0\\\\\\":0,\\\\\\"1\\\\\\":0},b:{},_coverageSchema:\\\\\\"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c\\\\\\"},coverage=global[gcv]||(global[gcv]={});if(coverage[path]&&coverage[path].hash===hash){return coverage[path];}coverageData.hash=hash;return coverage[path]=coverageData;}();++cov_2obfoewtj5.s[0];module.exports=class Foo{bar(){++cov_2obfoewtj5.f[0];++cov_2obfoewtj5.s[1];return!!this;}baz(){++cov_2obfoewtj5.f[1];++cov_2obfoewtj5.s[2];return!this.bar();}};\\\\n\\\\n\\\\n//////////////////\\\\n// WEBPACK FOOTER\\\\n// ./test/fixtures/basic.js\\\\n// module id = 0\\\\n// module chunks = 0\\"],\\"sourceRoot\\":\\"\\"}"`;

exports[`instrument code 1`] = `
"/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
Expand Down Expand Up @@ -70,10 +72,10 @@ exports[`instrument code 1`] = `
/* 0 */
/***/ (function(module, exports) {
var cov_2obfoewtj5=function(){var path=\\"/fixtures/basic.js\\",hash=\\"8d2a27e749a6c23469b4fbbe8fb8b59b371a5c4c\\",global=new Function('return this')(),gcv=\\"__coverage__\\",coverageData={path:\\"/fixtures/basic.js\\",statementMap:{\\"0\\":{start:{line:1,column:0},end:{line:11,column:1}},\\"1\\":{start:{line:4,column:4},end:{line:4,column:18}},\\"2\\":{start:{line:8,column:4},end:{line:8,column:23}}},fnMap:{\\"0\\":{name:\\"(anonymous_0)\\",decl:{start:{line:3,column:2},end:{line:3,column:3}},loc:{start:{line:3,column:8},end:{line:5,column:3}},line:3},\\"1\\":{name:\\"(anonymous_1)\\",decl:{start:{line:7,column:2},end:{line:7,column:3}},loc:{start:{line:7,column:8},end:{line:9,column:3}},line:7}},branchMap:{},s:{\\"0\\":0,\\"1\\":0,\\"2\\":0},f:{\\"0\\":0,\\"1\\":0},b:{},_coverageSchema:\\"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c\\"},coverage=global[gcv]||(global[gcv]={});if(coverage[path]&&coverage[path].hash===hash){return coverage[path];}coverageData.hash=hash;return coverage[path]=coverageData;}();++cov_2obfoewtj5.s[0];module.exports=class Foo{bar(){++cov_2obfoewtj5.f[0];++cov_2obfoewtj5.s[1];return!!this;}baz(){++cov_2obfoewtj5.f[1];++cov_2obfoewtj5.s[2];return!this.bar();}};
var cov_2obfoewtj5=function(){var path=\\"/fixtures/basic.js\\",hash=\\"d160bda36fc8432c2ffbb2cefc3c20475fdbdbec\\",global=new Function('return this')(),gcv=\\"__coverage__\\",coverageData={path:\\"/fixtures/basic.js\\",statementMap:{\\"0\\":{start:{line:1,column:0},end:{line:11,column:2}},\\"1\\":{start:{line:4,column:4},end:{line:4,column:18}},\\"2\\":{start:{line:8,column:4},end:{line:8,column:23}}},fnMap:{\\"0\\":{name:\\"(anonymous_0)\\",decl:{start:{line:3,column:2},end:{line:3,column:3}},loc:{start:{line:3,column:8},end:{line:5,column:3}},line:3},\\"1\\":{name:\\"(anonymous_1)\\",decl:{start:{line:7,column:2},end:{line:7,column:3}},loc:{start:{line:7,column:8},end:{line:9,column:3}},line:7}},branchMap:{},s:{\\"0\\":0,\\"1\\":0,\\"2\\":0},f:{\\"0\\":0,\\"1\\":0},b:{},_coverageSchema:\\"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c\\"},coverage=global[gcv]||(global[gcv]={});if(coverage[path]&&coverage[path].hash===hash){return coverage[path];}coverageData.hash=hash;return coverage[path]=coverageData;}();++cov_2obfoewtj5.s[0];module.exports=class Foo{bar(){++cov_2obfoewtj5.f[0];++cov_2obfoewtj5.s[1];return!!this;}baz(){++cov_2obfoewtj5.f[1];++cov_2obfoewtj5.s[2];return!this.bar();}};
/***/ })
/******/ ]);"
`;

exports[`sourcemap files 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///webpack/bootstrap 96367ef0e8ff4d152ddd\\",\\"webpack:///./test/fixtures/basic.js\\"],\\"names\\":[\\"module\\",\\"exports\\",\\"Foo\\",\\"bar\\",\\"baz\\"],\\"mappings\\":\\";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;mlCC7DAA,OAAOC,OAAP,CAAiB,KAAMC,IAAI,CAEzBC,KAAM,6CACJ,MAAO,CAAC,CAAC,IAAT,CACD,CAEDC,KAAM,6CACJ,MAAO,CAAC,KAAKD,GAAL,EAAR,CACD,CARwB,CAA3B,C\\",\\"file\\":\\"main.js\\",\\"sourcesContent\\":[\\" \\\\t// The module cache\\\\n \\\\tvar installedModules = {};\\\\n\\\\n \\\\t// The require function\\\\n \\\\tfunction __webpack_require__(moduleId) {\\\\n\\\\n \\\\t\\\\t// Check if module is in cache\\\\n \\\\t\\\\tif(installedModules[moduleId]) {\\\\n \\\\t\\\\t\\\\treturn installedModules[moduleId].exports;\\\\n \\\\t\\\\t}\\\\n \\\\t\\\\t// Create a new module (and put it into the cache)\\\\n \\\\t\\\\tvar module = installedModules[moduleId] = {\\\\n \\\\t\\\\t\\\\ti: moduleId,\\\\n \\\\t\\\\t\\\\tl: false,\\\\n \\\\t\\\\t\\\\texports: {}\\\\n \\\\t\\\\t};\\\\n\\\\n \\\\t\\\\t// Execute the module function\\\\n \\\\t\\\\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\\\\n\\\\n \\\\t\\\\t// Flag the module as loaded\\\\n \\\\t\\\\tmodule.l = true;\\\\n\\\\n \\\\t\\\\t// Return the exports of the module\\\\n \\\\t\\\\treturn module.exports;\\\\n \\\\t}\\\\n\\\\n\\\\n \\\\t// expose the modules object (__webpack_modules__)\\\\n \\\\t__webpack_require__.m = modules;\\\\n\\\\n \\\\t// expose the module cache\\\\n \\\\t__webpack_require__.c = installedModules;\\\\n\\\\n \\\\t// define getter function for harmony exports\\\\n \\\\t__webpack_require__.d = function(exports, name, getter) {\\\\n \\\\t\\\\tif(!__webpack_require__.o(exports, name)) {\\\\n \\\\t\\\\t\\\\tObject.defineProperty(exports, name, {\\\\n \\\\t\\\\t\\\\t\\\\tconfigurable: false,\\\\n \\\\t\\\\t\\\\t\\\\tenumerable: true,\\\\n \\\\t\\\\t\\\\t\\\\tget: getter\\\\n \\\\t\\\\t\\\\t});\\\\n \\\\t\\\\t}\\\\n \\\\t};\\\\n\\\\n \\\\t// getDefaultExport function for compatibility with non-harmony modules\\\\n \\\\t__webpack_require__.n = function(module) {\\\\n \\\\t\\\\tvar getter = module && module.__esModule ?\\\\n \\\\t\\\\t\\\\tfunction getDefault() { return module['default']; } :\\\\n \\\\t\\\\t\\\\tfunction getModuleExports() { return module; };\\\\n \\\\t\\\\t__webpack_require__.d(getter, 'a', getter);\\\\n \\\\t\\\\treturn getter;\\\\n \\\\t};\\\\n\\\\n \\\\t// Object.prototype.hasOwnProperty.call\\\\n \\\\t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\\\\n\\\\n \\\\t// __webpack_public_path__\\\\n \\\\t__webpack_require__.p = \\\\\\"\\\\\\";\\\\n\\\\n \\\\t// Load entry module and return exports\\\\n \\\\treturn __webpack_require__(__webpack_require__.s = 0);\\\\n\\\\n\\\\n\\\\n// WEBPACK FOOTER //\\\\n// webpack/bootstrap 96367ef0e8ff4d152ddd\\",\\"module.exports = class Foo {\\\\n\\\\n bar() {\\\\n return !!this;\\\\n }\\\\n\\\\n baz() {\\\\n return !this.bar();\\\\n }\\\\n\\\\n}\\\\n\\\\n\\\\n\\\\n// WEBPACK FOOTER //\\\\n// ./test/fixtures/basic.js\\"],\\"sourceRoot\\":\\"\\"}"`;
exports[`sourcemap files on by default 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///webpack/bootstrap 1ae028e11f9e6449a2dd\\",\\"webpack:///./test/fixtures/basic.js\\"],\\"names\\":[\\"module\\",\\"exports\\",\\"Foo\\",\\"bar\\",\\"baz\\"],\\"mappings\\":\\";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;mlCC7DAA,OAAOC,OAAP,CAAiB,KAAMC,IAAI,CAEzBC,KAAM,6CACJ,MAAO,CAAC,CAAC,IAAT,CACD,CAEDC,KAAM,6CACJ,MAAO,CAAC,KAAKD,GAAL,EAAR,CACD,CARwB,CAA3B,C\\",\\"file\\":\\"main.js\\",\\"sourcesContent\\":[\\" \\\\t// The module cache\\\\n \\\\tvar installedModules = {};\\\\n\\\\n \\\\t// The require function\\\\n \\\\tfunction __webpack_require__(moduleId) {\\\\n\\\\n \\\\t\\\\t// Check if module is in cache\\\\n \\\\t\\\\tif(installedModules[moduleId]) {\\\\n \\\\t\\\\t\\\\treturn installedModules[moduleId].exports;\\\\n \\\\t\\\\t}\\\\n \\\\t\\\\t// Create a new module (and put it into the cache)\\\\n \\\\t\\\\tvar module = installedModules[moduleId] = {\\\\n \\\\t\\\\t\\\\ti: moduleId,\\\\n \\\\t\\\\t\\\\tl: false,\\\\n \\\\t\\\\t\\\\texports: {}\\\\n \\\\t\\\\t};\\\\n\\\\n \\\\t\\\\t// Execute the module function\\\\n \\\\t\\\\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\\\\n\\\\n \\\\t\\\\t// Flag the module as loaded\\\\n \\\\t\\\\tmodule.l = true;\\\\n\\\\n \\\\t\\\\t// Return the exports of the module\\\\n \\\\t\\\\treturn module.exports;\\\\n \\\\t}\\\\n\\\\n\\\\n \\\\t// expose the modules object (__webpack_modules__)\\\\n \\\\t__webpack_require__.m = modules;\\\\n\\\\n \\\\t// expose the module cache\\\\n \\\\t__webpack_require__.c = installedModules;\\\\n\\\\n \\\\t// define getter function for harmony exports\\\\n \\\\t__webpack_require__.d = function(exports, name, getter) {\\\\n \\\\t\\\\tif(!__webpack_require__.o(exports, name)) {\\\\n \\\\t\\\\t\\\\tObject.defineProperty(exports, name, {\\\\n \\\\t\\\\t\\\\t\\\\tconfigurable: false,\\\\n \\\\t\\\\t\\\\t\\\\tenumerable: true,\\\\n \\\\t\\\\t\\\\t\\\\tget: getter\\\\n \\\\t\\\\t\\\\t});\\\\n \\\\t\\\\t}\\\\n \\\\t};\\\\n\\\\n \\\\t// getDefaultExport function for compatibility with non-harmony modules\\\\n \\\\t__webpack_require__.n = function(module) {\\\\n \\\\t\\\\tvar getter = module && module.__esModule ?\\\\n \\\\t\\\\t\\\\tfunction getDefault() { return module['default']; } :\\\\n \\\\t\\\\t\\\\tfunction getModuleExports() { return module; };\\\\n \\\\t\\\\t__webpack_require__.d(getter, 'a', getter);\\\\n \\\\t\\\\treturn getter;\\\\n \\\\t};\\\\n\\\\n \\\\t// Object.prototype.hasOwnProperty.call\\\\n \\\\t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\\\\n\\\\n \\\\t// __webpack_public_path__\\\\n \\\\t__webpack_require__.p = \\\\\\"\\\\\\";\\\\n\\\\n \\\\t// Load entry module and return exports\\\\n \\\\treturn __webpack_require__(__webpack_require__.s = 0);\\\\n\\\\n\\\\n\\\\n// WEBPACK FOOTER //\\\\n// webpack/bootstrap 1ae028e11f9e6449a2dd\\",\\"module.exports = class Foo {\\\\n\\\\n bar() {\\\\n return !!this;\\\\n }\\\\n\\\\n baz() {\\\\n return !this.bar();\\\\n }\\\\n\\\\n};\\\\n\\\\n\\\\n\\\\n// WEBPACK FOOTER //\\\\n// ./test/fixtures/basic.js\\"],\\"sourceRoot\\":\\"\\"}"`;
14 changes: 12 additions & 2 deletions test/index.test.js
Expand Up @@ -6,13 +6,23 @@ test('instrument code', async () => {
expect(instrumentedSource).toMatchSnapshot();
});

test('sourcemap files', async () => {
test('sourcemap files on by default', async () => {
const stats = await runWebpack(webpackConfigFactory({
extra: {
devtool: 'sourcemap',
},
}));
const sourceMap = stats.compilation.assets['main.js.map'].source();
expect(sourceMap).toMatchSnapshot();
});

test('disabled sourcemaps', async () => {
const stats = await runWebpack(webpackConfigFactory({
extra: {
devtool: 'sourcemap',
},
instrumenterOptions: {
produceSourceMap: true,
produceSourceMap: false,
},
}));
const sourceMap = stats.compilation.assets['main.js.map'].source();
Expand Down

0 comments on commit 7e686b9

Please sign in to comment.