Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
rollup sourcemaps sources correction, handle sanitization entirely in…
Browse files Browse the repository at this point in the history
… loader
  • Loading branch information
guybedford committed May 18, 2016
1 parent 1a25fd0 commit 8316062
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion compilers/esm.js
Expand Up @@ -58,7 +58,7 @@ exports.attach = function(loader) {
var babel = require('babel-core');
var output = babel.transform(load.source, {
babelrc: false,
filename: load.address,
filename: load.path,
inputSourceMap: load.metadata.sourceMap,
ast: true,
resolveModuleSource: function(dep) {
Expand Down
7 changes: 7 additions & 0 deletions lib/rollup.js
Expand Up @@ -274,6 +274,13 @@ exports.rollupTree = function(loader, tree, entryPoints, traceOpts, compileOpts)

var output = bundle.generate(generateOptions);

// convert sources list into paths
// no input source maps support, so nothing more to worry about here
if (output.map)
output.map.sources = output.map.sources.map(function(name) {
return tree[name].path;
});

if (fullTreeRollup)
return {
source: output.code,
Expand Down
18 changes: 0 additions & 18 deletions lib/trace.js
Expand Up @@ -458,24 +458,6 @@ Trace.prototype.getLoadRecord = function(canonical, excludeURLs, parentStack) {
}
}

// sanitize source map
var sourceMap = load.metadata.sourceMap;
if (sourceMap) {
if (typeof sourceMap == 'string')
sourceMap = load.metadata.sourceMap = JSON.parse(sourceMap);

if (load.metadata.loader) {
var originalName = load.name.split('!')[0];

// force set the filename of the original file
sourceMap.file = originalName + '!transpiled';

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

// normalize dependencies to populate depMap
return Promise.all(result.deps.map(function(dep) {
return loader.normalize(dep, normalized, address)
Expand Down

0 comments on commit 8316062

Please sign in to comment.