Browse Source

add file property to sourcemaps with plugins

gh-1187
Rich-Harris 8 years ago
parent
commit
1032e75d46
  1. 2
      src/Bundle.js
  2. 4
      src/utils/collapseSourcemaps.js

2
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 );
}

4
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

Loading…
Cancel
Save