From 1032e75d462c5941fccd36c5f315919b31a4410b Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Thu, 5 Jan 2017 10:41:18 -0500 Subject: [PATCH] add file property to sourcemaps with plugins --- src/Bundle.js | 2 +- src/utils/collapseSourcemaps.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle.js b/src/Bundle.js index 0cfe895..879c525 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -515,7 +515,7 @@ export default class Bundle { if ( file ) file = resolve( typeof process !== 'undefined' ? process.cwd() : '', file ); if ( this.hasLoaders || find( this.plugins, plugin => plugin.transform || plugin.transformBundle ) ) { - map = magicString.generateMap( {} ); + map = magicString.generateMap({}); if ( typeof map.mappings === 'string' ) { map.mappings = decode( map.mappings ); } diff --git a/src/utils/collapseSourcemaps.js b/src/utils/collapseSourcemaps.js index bd65cf4..8a7b995 100644 --- a/src/utils/collapseSourcemaps.js +++ b/src/utils/collapseSourcemaps.js @@ -1,6 +1,6 @@ import { encode } from 'sourcemap-codec'; import error from './error.js'; -import { dirname, relative, resolve } from './path.js'; +import { basename, dirname, relative, resolve } from './path.js'; class Source { constructor ( filename, content ) { @@ -159,6 +159,8 @@ export default function collapseSourcemaps ( bundle, file, map, modules, bundleS if ( file ) { const directory = dirname( file ); sources = sources.map( source => relative( directory, source ) ); + + map.file = basename( file ); } // we re-use the `map` object because it has convenient toString/toURL methods