From b334245674a814bff156e79595e417a21d24b6d5 Mon Sep 17 00:00:00 2001 From: Brendan Baldwin Date: Thu, 10 Jan 2019 14:31:10 -0800 Subject: [PATCH] [bundler] Tiny updates to code for removing empty bundles and trim redundant exclude processing code. (#3327) * [bundler] Tiny updates to code for removing empty bundles and trim redundant exclude processing code. * [bundler ] Unresolveable URLs should not remain in the excludes set when Bundler is instantiated. --- packages/bundler/src/bundler.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/bundler/src/bundler.ts b/packages/bundler/src/bundler.ts index c92a51d8d..ee5084f5e 100644 --- a/packages/bundler/src/bundler.ts +++ b/packages/bundler/src/bundler.ts @@ -94,7 +94,8 @@ export class Bundler { } this.excludes = Array.isArray(opts.excludes) ? - opts.excludes.map((url) => this.analyzer.resolveUrl(url)!) : + opts.excludes.map((url) => this.analyzer.resolveUrl(url)!) + .filter((url) => !!url) : []; this.stripComments = Boolean(opts.stripComments); this.enableCssInlining = @@ -202,12 +203,8 @@ export class Bundler { // Remove excluded files from bundles. for (const bundle of bundles) { for (const exclude of this.excludes) { - const resolvedExclude = this.analyzer.resolveUrl(exclude); - if (!resolvedExclude) { - continue; - } - bundle.files.delete(resolvedExclude); - const excludeAsFolder = resolvedExclude.endsWith('/') ? resolvedExclude : resolvedExclude + '/'; + bundle.files.delete(exclude); + const excludeAsFolder = exclude.endsWith('/') ? exclude : exclude + '/'; for (const file of bundle.files) { if (file.startsWith(excludeAsFolder)) { bundle.files.delete(file); @@ -218,7 +215,7 @@ export class Bundler { let b = 0; while (b < bundles.length) { - if (bundles[b].files.size < 0) { + if (bundles[b].files.size <= 0) { bundles.splice(b, 1); continue; }