Difference between simple import statement and System.import in ES6 Module Loader
Asked Answered
C

1

2

Is anybody able to explain the difference between a simple import and a System.import statement of the ES6 Module Loader (or Polyfills like System.js, Webpack etc.)

Something like

System.import('https://code.jquery.com/jquery.js').then();

seems to be possible, as well as a simple

 import 'jquery';

Is System.import the only possibility to have a callback after the import statement?

Cletacleti answered 18/6, 2015 at 8:9 Comment(1)
They have just different use cases. System.import allows you to load modules dynamically. import does not allow that but doesn't require you to use callbacks.Lanthanide
M
6

You can use the System.import inside <script> tags where import aren't supported, and you can also load modules conditionally.

So you can programmatically import a module, via an API based on ES6 promises, in addition of the declarative syntax for working with modules that is the ES6 import.

Melamine answered 18/6, 2015 at 9:34 Comment(1)
< script > tags, sorry (inside your index.html or someName.html file)Melamine

© 2022 - 2024 — McMap. All rights reserved.