steal-clone
steal.steal-clone
{function()}
Steal-clone is a module that allows you to clone Steal's loader and provide module definitions that will be used when doing dynamic imports.
clone(moduleOverrides)
Parameters
-
moduleOverrides
{Object}Module identifiers and definitions used to override modules of the same name. These definitions will be used when importing parent modules using the
importstatement of the returned loader.
Returns
{Object}
The cloned loader.
Use
If you have
moduleAdefined as:and
moduleBdefined as:You can use
cloneto override the definition of moduleB that will be used from within moduleA:Module Identifiers
The keys passed in the
moduleOverridesobject ("moduleB" in the example above) can be any valid module identifier. All of the module syntaxes supported by Steal are supported by steal-clone. If you're using ES6 modules, you can use the same value used in your import statement. Similarly, if you're using CommonJS, you can use the same value that you pass to 'require'.You can also use relative paths to override modules based on where you are using steal-clone:
Module Definitions
The values passed in the
moduleOverridesobject define the exports for that module. In the above example,moduleBhas a single default export.If
moduleBis defined like:You can override both of the module's exports like this:
Dynamically imported modules
It's possible to provide overrides to modules that will be later dynamically imported. If you have a
moduleCdefined as:You will be able to override the value of
moduleB. Note that for this to work you must import @loader to use for dynamic loading instead of usingsteal.import. This is because@loaderwill refer to the cloned loader you created where assteal.loaderalways refers back to the global loader. Using @loader is always recommended anyways.Use with npm
Steal-clone can be used to override dependencies from npm in the same way as any other module.