fusionjs / fusion-cli

Migrated to https://github.com/fusionjs/fusionjs
MIT License
140 stars 37 forks source link

Fix preloading when chunk group contains multiple chunks #725

Closed rtsao closed 5 years ago

rtsao commented 5 years ago

In some instances, chunks would not be preloaded when they should.

This would occur in a scenario like the following:

// main.js
import("./a.js");
import("./b.js");
// a.js
import shared from "./shared.js";
export default "a";
// b.js
import shared from "./shared.js";
export default "b";
// shared.js
export default "shared";

This would yield the following chunks (simplified naming)

In webpack terminology, these chunks fit into three chunk groups:

The bug

chunk-shared.js would not be preloaded because the import()s for a.js and b.js would only be instrumented with the chunk ids for the chunk-a.js and chunk-b.js chunks, respectively.

A side effect of this meant that any translations in shared.js would be SSR'd, but would be missing on the initial client-side render because these translations would not be inlined into the SSR.

This PR ensures that chunk-shared.js is also added to the import promise instrumentation, ensuring that chunk-shared.js is preloaded correctly along with either chunk-a.js or chunk-b.js

rtsao commented 5 years ago

!merge

old-fusion-bot[bot] commented 5 years ago

Triggered Fusion.js build verification: https://buildkite.com/uberopensource/fusion-release-verification/builds/1661