Trying for the simplest explanation. This is the file that will be transpiled and bundled:
//app.js
import "my-static-module";
if(some_condition_is_true){
import ("my-dynamic-module")
}
console.log("My app is running")
Now see how different optimization types will treat it.
async (default):
Two files will be created.
- bundle.js (includes app.js + my-static-module)
- chunk.js (includes my-dynamic-module only)
initial:
Three files will be created
- app.js (includes only app.js)
- bundle.js (includes only my-static-module)
- chunk.js (includes only my-dynamic-module)
all:
Two files will be created
- app.js (includes app.js only)
- bundle.js (includes my-static-module + my-dynamic-module)
“all” will have the smallest overall size.