Skip to content

Commit

Permalink
[bundler] Tiny updates to code for removing empty bundles and trim re…
Browse files Browse the repository at this point in the history
…dundant 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.
  • Loading branch information
usergenic authored Jan 10, 2019
1 parent b3633e0 commit b334245
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/bundler/src/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit b334245

Please sign in to comment.