Skip to content

Commit

Permalink
source maps sanitization relaxing
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 18, 2016
1 parent 36f995e commit b124515
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/esm.js
Expand Up @@ -55,13 +55,14 @@
// sanitize sourceMap if an object not a JSON string
var sourceMap = load.metadata.sourceMap;
if (sourceMap && typeof sourceMap == 'object') {
var originalName = load.name.split('!')[0];
var originalName = load.address.split('!')[0];

// force set the filename of the original file
sourceMap.file = originalName + '!transpiled';
if (!sourceMap.file || sourceMap.file == load.address)
sourceMap.file = originalName + '!transpiled';

// force set the sources list if only one source
if (!sourceMap.sources || sourceMap.sources.length <= 1)
if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
sourceMap.sources = [originalName];
}

Expand Down
7 changes: 4 additions & 3 deletions lib/plugins.js
Expand Up @@ -203,13 +203,14 @@
if (typeof sourceMap != 'object')
throw new Error('load.metadata.sourceMap must be set to an object.');

var originalName = load.name.split('!')[0];
var originalName = load.address.split('!')[0];

// force set the filename of the original file
sourceMap.file = originalName + '!transpiled';
if (!sourceMap.file || sourceMap.file == load.address)
sourceMap.file = originalName + '!transpiled';

// force set the sources list if only one source
if (!sourceMap.sources || sourceMap.sources.length <= 1)
if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
sourceMap.sources = [originalName];
}

Expand Down

0 comments on commit b124515

Please sign in to comment.