Skip to content

Commit

Permalink
Deterministic Bundle Trees
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Dec 19, 2017
1 parent 6731049 commit 539ade1
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,23 +322,32 @@ class Bundler extends EventEmitter {
}
}

// Process asset dependencies
await Promise.all(
// Resolve and load asset dependencies
let assetDeps = await Promise.all(
dependencies.map(async dep => {
let assetDep = await this.resolveDep(asset, dep);
if (dep.includedInParent) {
// This dependency is already included in the parent's generated output,
// so no need to load it. We map the name back to the parent asset so
// that changing it triggers a recompile of the parent.
this.loadedAssets.set(dep.name, asset);
} else {
asset.dependencies.set(dep.name, dep);
asset.depAssets.set(dep.name, assetDep);
if (!dep.includedInParent) {
await this.loadAsset(assetDep);
}

return assetDep;
})
);

// Store resolved assets in their original order
dependencies.forEach((dep, i) => {
let assetDep = assetDeps[i];
if (dep.includedInParent) {
// This dependency is already included in the parent's generated output,
// so no need to load it. We map the name back to the parent asset so
// that changing it triggers a recompile of the parent.
this.loadedAssets.set(dep.name, asset);
} else {
asset.dependencies.set(dep.name, dep);
asset.depAssets.set(dep.name, assetDep);
}
});

this.buildQueue.delete(asset);
}

Expand Down

0 comments on commit 539ade1

Please sign in to comment.