Guard against undefined filename

pull/1863/head
Timothy Johnson 7 years ago
parent 3e8452d26d
commit 01bdc9ac3b

@ -92,10 +92,11 @@ async function replaceTagContents(
// Shift sourcemap to the appropriate line // Shift sourcemap to the appropriate line
if (processed.map) { if (processed.map) {
const consumer = new SourceMapConsumer(processed.map); const consumer = new SourceMapConsumer(processed.map);
const generator = new SourceMapGenerator(
const generator = new SourceMapGenerator({ options.filename
file: relative(process.cwd(), options.filename), ? { file: relative(process.cwd(), options.filename) }
}); : {}
);
consumer.eachMapping(mapping => { consumer.eachMapping(mapping => {
generator.addMapping({ generator.addMapping({
source: mapping.source, source: mapping.source,
@ -172,9 +173,9 @@ export default async function preprocess(
} }
} }
let allMaps = new SourceMapGenerator({ let allMaps = new SourceMapGenerator(
file: relative(process.cwd(), options.filename), options.filename ? { file: relative(process.cwd(), options.filename) } : {}
}); );
if (!!style) { if (!!style) {
const { code, map } = await replaceTagContents(source, 'style', style, options); const { code, map } = await replaceTagContents(source, 'style', style, options);

Loading…
Cancel
Save