I want to use es6 modules and Systemjs. But I do not understand one thing. For example I have such my-module1.js file:
'use strict';
import myModule2 from './my-module2.js';
myModule2();
// some additional code goes here
Here is my-module2.js file content:
'use strict';
export default function myModule2() {
// some additional code goes here
}
and here is part of index.html:
<script>
'use strict';
System.import('./my-module1.js').then(function() {
});
</script>
Two questions:
1) When Systemjs will load my-module1.js it will find import operator. Will Systemjs load file which is in import operator? Or Systemjs does not work with import operator?
2) In future when browsers support es6 modules, when browser find files with import operator, will browser synchronously load these files or asynchronously? I mean if browser load these files synchronously, will user actions(such as mouse click, mouse hover, keyup etc) work or browser page will be blocked? It happens when you for example do synchronous xhr request.
First part of question: Systemjs will execute the import statement, provided your httpserver is serving the files.
Second part of question: YES. ES6 Modules are loaded Synchronously or Asynchronously?
"ES6 module loaders will be asynchronous."