From 01bdc9ac3bb5d142bcf42e12ad35b3fcbb8fe9b7 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Sun, 2 Dec 2018 12:13:57 -0800 Subject: [PATCH] Guard against undefined filename --- src/preprocess/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/preprocess/index.ts b/src/preprocess/index.ts index bc06878df2..e72c1c3cec 100644 --- a/src/preprocess/index.ts +++ b/src/preprocess/index.ts @@ -92,10 +92,11 @@ async function replaceTagContents( // Shift sourcemap to the appropriate line if (processed.map) { const consumer = new SourceMapConsumer(processed.map); - - const generator = new SourceMapGenerator({ - file: relative(process.cwd(), options.filename), - }); + const generator = new SourceMapGenerator( + options.filename + ? { file: relative(process.cwd(), options.filename) } + : {} + ); consumer.eachMapping(mapping => { generator.addMapping({ source: mapping.source, @@ -172,9 +173,9 @@ export default async function preprocess( } } - let allMaps = new SourceMapGenerator({ - file: relative(process.cwd(), options.filename), - }); + let allMaps = new SourceMapGenerator( + options.filename ? { file: relative(process.cwd(), options.filename) } : {} + ); if (!!style) { const { code, map } = await replaceTagContents(source, 'style', style, options);