Difference between System.import() and import()? Difference between System.import() and import()? javascript javascript

Difference between System.import() and import()?


The important part of your first quote is

specification being written

When Webpack 1 implemented System.import, the spec was still evolving. If fact it still is. Webpack 1 implemented System.import because that was what was being tossed around as the potential API at the time.

Webpack 2 implements import() because that is a new proposal to standardize on a syntactic approach rather library-based one.


Here's what you're looking for: tc39 Proposal for Import

An actual function

Drafts of the Loader ideas collection have at various times had actual functions (not just function-like syntactic forms) named System.import() or System.loader.import() or similar, which accomplish the same use cases.

The biggest problem here, as previously noted by the spec's editors, is how to interpret the specifier argument to these functions. Since these are just functions, which are the same across the entire Realm and do not vary per script or module, the function must interpret its argument the same no matter from where it is called. (Unless something truly weird like stack inspection is implemented.) So likely this runs into similar problems as the document base URL issue for the importModule function above, where relative module specifiers become a bug farm and mismatch any nearby import declarations.