A promise that will resolve with the value of the module. It will resolve once the module and all of the module's dependencies have been fully resolved and executed.
Use
steal.loader.import is used to dynamically import a module. This is counter to the syntaxes which are statically parsed and dependencies loaded prior to running the code. In the following example we are importing the "lodash" module and assigning it's value to the _ variable in the Promise callback function.
Typically you won't need to use steal.loader.import very often in your application. There are two primary cases when you might want to use it:
Load a module whose moduleName is determined at runtime. If you need to concat a string in order to determine which module to load, steal.loader.import is a good candidate:
For use with progressive loading. If you use bundle in your application to determine bundles that will be progressively loaded, you use steal.loader.import to load a particular bundle. For example, if one of your bundles is checkout you would load that dynamically with steal.loader.import("checkout").
Use
steal.loader.import
is used to dynamically import a module. This is counter to the syntaxes which are statically parsed and dependencies loaded prior to running the code. In the following example we are importing the "lodash" module and assigning it's value to the_
variable in the Promise callback function.When to use
Typically you won't need to use
steal.loader.import
very often in your application. There are two primary cases when you might want to use it:Load a module whose moduleName is determined at runtime. If you need to concat a string in order to determine which module to load,
steal.loader.import
is a good candidate:For use with progressive loading. If you use bundle in your application to determine bundles that will be progressively loaded, you use
steal.loader.import
to load a particular bundle. For example, if one of your bundles ischeckout
you would load that dynamically withsteal.loader.import("checkout")
.