ES6模块语法的代码分割。
import 导入模块是同步的。import(module: string) -> Promise 语法可以异步导入模块。在webpack中会将该模块打包成单独的chunk文件。
example.js
import a from "a";import("b").then(function(b) {console.log("b loaded", b);})function loadC(name) {return import("c/" + name);}Promise.all([loadC("1"), loadC("2")]).then(function(arr) {console.log("c/1 and c/2 loaded", arr);});
