can.import
Imports a module with the underlying module loader.
util.import(moduleName)
Imports a module with the underlying module loader.
Parameters
-
moduleName
{String}
The module name to load. Example:
components/my-component
.
Returns
{Promise}
A promise that resolves if the module was successfully loaded and is rejected if the module can not be successfully loaded.
Use
can.import
is used internally by can.autorender when it finds <can-import> tags to import those modules before rendering the template.In the following example,
can.import
will import"components/my-component"
prior to the template being rendered.Module Loaders
can.import
looks first for aSystem
loader, followed byrequire.amd
, followed bysteal
followed by a CommonJSrequire
.