From cf5dee06d589f63b29a41d5335a94f2d6ce38590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Tue, 3 May 2016 12:38:29 +0200 Subject: [PATCH] Update collapseSourcemaps to use class syntax post-620 --- src/utils/collapseSourcemaps.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/utils/collapseSourcemaps.js b/src/utils/collapseSourcemaps.js index 431a85e..ff86eaf 100644 --- a/src/utils/collapseSourcemaps.js +++ b/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 ) => {