populate map.sources and map.sourcesContent even if none of the original code is used

pull/295/head
Rich Harris 8 years ago
parent c1ba7638ce
commit 42497fd1aa

@ -149,6 +149,15 @@ export default class Generator {
const { filename } = options;
// special case — the source file doesn't actually get used anywhere. we need
// to add an empty file to populate map.sources and map.sourcesContent
if ( !parts.length ) {
compiled.addSource({
filename,
content: new MagicString( this.source ).remove( 0, this.source.length )
});
}
parts.forEach( str => {
const chunk = str.replace( pattern, '' );
if ( chunk ) addString( chunk );

@ -0,0 +1,9 @@
const fs = require( 'fs' );
const path = require( 'path' );
export function test ({ assert, map }) {
assert.deepEqual( map.sources, [ 'input.html' ]);
assert.deepEqual( map.sourcesContent, [
fs.readFileSync( path.join( __dirname, 'input.html' ), 'utf-8' )
]);
}
Loading…
Cancel
Save