Use import() instead of System.import in examples

This commit is contained in:
Simon Legner 2017-02-13 08:48:43 +01:00
parent 1cc7272c17
commit 278a3b00a8
4 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import vendor from "./vendor";
// some module
System.import("./async1");
System.import("./async2");
import("./async1");
import("./async2");

View File

@ -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) {

View File

@ -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

View File

@ -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);
});