From e2103a9612b18368a892b9bbcbc661c691248ab9 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sat, 23 Apr 2022 00:02:25 -0400 Subject: [PATCH] Flip conditional --- src/build-source-map-tree.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/build-source-map-tree.ts b/src/build-source-map-tree.ts index 7265d2f..32213ca 100644 --- a/src/build-source-map-tree.ts +++ b/src/build-source-map-tree.ts @@ -71,19 +71,16 @@ function build( const { source, content } = ctx; - // If there is no sourcemap, then it is an unmodified source file. - if (!sourceMap) { - // The contents of this unmodified source file can be overridden via the loader context, - // allowing it to be explicitly null or a string. If it remains undefined, we fall back to - // the importing sourcemap's `sourcesContent` field. - const sourceContent = - content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; - return OriginalSource(source, sourceContent); - } + // If there is a sourcemap, then we need to recurse into it to load its source files. + if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth); - // Else, it's a real sourcemap, and we need to recurse into it to load its - // source files. - return build(new TraceMap(sourceMap, source), loader, source, depth); + // Else, it's an an unmodified source file. + // The contents of this unmodified source file can be overridden via the loader context, + // allowing it to be explicitly null or a string. If it remains undefined, we fall back to + // the importing sourcemap's `sourcesContent` field. + const sourceContent = + content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; + return OriginalSource(source, sourceContent); }); return MapSource(map, children);