Browse Source

Update collapseSourcemaps to use class syntax post-620

gh-669
Oskar Segersvärd 9 years ago
parent
commit
cf5dee06d5
  1. 30
      src/utils/collapseSourcemaps.js

30
src/utils/collapseSourcemaps.js

@ -1,25 +1,25 @@
import { encode, decode } from 'sourcemap-codec';
function Source ( index ) {
this.isOriginal = true;
this.index = index;
}
class Source {
constructor ( index ) {
this.isOriginal = true;
this.index = index;
}
Source.prototype = {
traceSegment ( line, column, name ) {
return { line, column, name, index: this.index };
}
};
}
function Link ( map, sources ) {
if ( !map ) throw new Error( 'Cannot generate a sourcemap if non-sourcemap-generating transformers are used' );
class Link {
constructor ( map, sources ) {
if ( !map ) throw new Error( 'Cannot generate a sourcemap if non-sourcemap-generating transformers are used' );
this.sources = sources;
this.names = map.names;
this.mappings = decode( map.mappings );
}
this.sources = sources;
this.names = map.names;
this.mappings = decode( map.mappings );
}
Link.prototype = { // TODO bring into line with others post-https://github.com/rollup/rollup/pull/386
traceMappings () {
let names = [];
@ -57,7 +57,7 @@ Link.prototype = { // TODO bring into line with others post-https://github.com/r
});
return { names, mappings };
},
}
traceSegment ( line, column, name ) {
const segments = this.mappings[ line ];
@ -79,7 +79,7 @@ Link.prototype = { // TODO bring into line with others post-https://github.com/r
return null;
}
};
}
export default function collapseSourcemaps ( map, modules, bundleSourcemapChain ) {
const sources = modules.map( ( module, i ) => {

Loading…
Cancel
Save