mirror of https://github.com/webpack/webpack.git
Use import() instead of System.import in examples
This commit is contained in:
parent
1cc7272c17
commit
278a3b00a8
|
|
@ -1,4 +1,4 @@
|
|||
import vendor from "./vendor";
|
||||
// some module
|
||||
System.import("./async1");
|
||||
System.import("./async2");
|
||||
import("./async1");
|
||||
import("./async2");
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import a from "a";
|
||||
|
||||
System.import("b").then(function(b) {
|
||||
import("b").then(function(b) {
|
||||
console.log("b loaded", b);
|
||||
})
|
||||
|
||||
function loadC(name) {
|
||||
return System.import("c/" + name)
|
||||
return import("c/" + name);
|
||||
}
|
||||
|
||||
Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ This example show how to use Code Splitting with the ES6 module syntax.
|
|||
|
||||
The standard `import` is sync.
|
||||
|
||||
`System.import(module: string) -> Promise` can be used to load modules on demand. This acts as split point for webpack and creates a chunk.
|
||||
`import(module: string) -> Promise` can be used to load modules on demand. This acts as split point for webpack and creates a chunk.
|
||||
|
||||
Providing dynamic expressions to `System.import` is possible. The same limits as with dynamic expressions in `require` calls apply here. Each possible module creates an additional chunk. In this example `System.import("c/" + name)` creates two additional chunks (one for each file in `node_modules/c/`). This is called "async context".
|
||||
Providing dynamic expressions to `import` is possible. The same limits as with dynamic expressions in `require` calls apply here. Each possible module creates an additional chunk. In this example `import("c/" + name)` creates two additional chunks (one for each file in `node_modules/c/`). This is called "async context".
|
||||
|
||||
# example.js
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ var a = 1;
|
|||
inc(a); // 2
|
||||
|
||||
// async loading
|
||||
System.import("./async-loaded").then(function(asyncLoaded) {
|
||||
import("./async-loaded").then(function(asyncLoaded) {
|
||||
console.log(asyncLoaded);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue