From 80441f99a74f1997e9fe9405a889e42427fb88c0 Mon Sep 17 00:00:00 2001 From: Floris Bernard Date: Mon, 25 Jul 2016 09:42:44 +0200 Subject: [PATCH] Fix sourcemap support for karma Remove karma-source-map-support dependency, it is no longer needed. The karma-sourcemap-loader module will handle source maps for us. Add the sourcemap preprocessor to the test files as well so the test file line numbers also match. Instead of the devtool option in the webpack test config, use the SourceMapDevToolPlugin. This will also generate source maps on files with a .ts extension. Fixes #15 --- config/webpack.config.test.js | 12 +++++++----- karma.conf.js | 5 +++-- package.json | 1 - 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/webpack.config.test.js b/config/webpack.config.test.js index 37674e3..e2e984e 100644 --- a/config/webpack.config.test.js +++ b/config/webpack.config.test.js @@ -5,11 +5,6 @@ var path = require('path'); module.exports = function() { return { - /** - * Inline source maps, generated by TypeScript compiler, will be used. - */ - devtool: 'inline-source-map', - resolve: { extensions: ['', '.ts', '.js'] }, @@ -51,5 +46,12 @@ module.exports = function() } ] }, + // we use this instead of the devtool option, to force sourcemap generation for .ts files + plugins: [ + new webpack.SourceMapDevToolPlugin({ + filename: null, + test: /\.(t|j|cs)s($|\?)/i + }) + ] }; }; diff --git a/karma.conf.js b/karma.conf.js index f6692e4..640bc96 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -8,7 +8,7 @@ module.exports = function(config) // List of test frameworks we will use. Most of them are provided by separate packages (adapters). // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai', 'source-map-support'], + frameworks: ['mocha', 'chai'], // Entry point / test environment builder is also written in TypeScript. files: [ @@ -27,7 +27,8 @@ module.exports = function(config) 'coverage' ], './test/**/*.ts': [ - 'webpack' + 'webpack', + 'sourcemap' ] }, diff --git a/package.json b/package.json index c7172e6..bd1b694 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "karma-mocha": "^1.1.1", "karma-phantomjs-launcher": "^1.0.0", "karma-remap-istanbul": "^0.1.1", - "karma-source-map-support": "^1.1.0", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^1.7.0", "marked": "^0.3.5",