From 6ba5476e9e378f24ac98e96040adc4599c229479 Mon Sep 17 00:00:00 2001 From: guybedford Date: Wed, 18 May 2016 19:22:12 +0200 Subject: [PATCH] source maps debugging --- compilers/esm.js | 2 +- lib/sourcemaps.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compilers/esm.js b/compilers/esm.js index b50b8e0..90b9a06 100644 --- a/compilers/esm.js +++ b/compilers/esm.js @@ -89,7 +89,7 @@ exports.compile = function(load, opts, loader) { var babelOptions = { babelrc: false, plugins: [[require('babel-plugin-transform-es2015-modules-systemjs'), { systemGlobal: opts.systemGlobal }]], - filename: load.address, + filename: load.path, sourceMaps: opts.sourceMaps, inputSourceMap: load.metadata.sourceMap, moduleIds: !opts.anonymous, diff --git a/lib/sourcemaps.js b/lib/sourcemaps.js index adaa37c..33de894 100644 --- a/lib/sourcemaps.js +++ b/lib/sourcemaps.js @@ -59,7 +59,7 @@ exports.concatenateSourceMaps = function(outFile, mapsWithOffsets, basePath, sou } wrapSourceMap(map).eachMapping(function(mapping) { - if (mapping.source.match(/(\/|^)@traceur/)) + if (!mapping.originalLine || !mapping.originalColumn || !mapping.source || mapping.source.match(/(\/|^)@traceur/)) return; generated.addMapping({ @@ -82,13 +82,15 @@ exports.concatenateSourceMaps = function(outFile, mapsWithOffsets, basePath, sou if (sourceMapContents) { normalized.sourcesContent = normalized.sources.map(function(source) { - //if (contentsBySource[source]) - // return contentsBySource[source]; + if (contentsBySource[source]) + return contentsBySource[source]; - try { return fs.readFileSync(path.resolve(basePath, source)).toString(); } catch (e) {} - - // remove this if optimistic return is reliable - return contentsBySource[source]; + try { + return fs.readFileSync(path.resolve(basePath, source)).toString(); + } + catch (e) { + return ""; + } }); }