npm
{*}
moduleName!npm
Parameters
-
moduleName
{moduleName}The moduleName of the file you want to process. This will normally be a package.json of your base application.
{*}
{moduleName}The moduleName of the file you want to process. This will normally be a package.json of your base application.
Use
The
npmplugin makes it easy to work with npm packages. By pointing it at apackage.json, you will be able to import npm packages as modules.By default, if stealPath points to steal.js within node_modules like:
configMain will point to
"package.json!npm". Thenpmplugin readspackage.jsonand sets a normalize and locate hook.Note: if you are using npm 3 see the npmAlgorithm option below.
npm Module names
Package dependency module names are converted to look like:
For example, code that import's jQuery like:
might actually import:
Configuration
package.jsonconfigures the behavior of a package and even dependency packages. This section lists the configurable properties and behaviors that steal uses.package.main
Specifies the main property unless it is overwritten by
package.browserorpackage.steal.main.package.browser
Specifies browser-specific overwrites for module file resolution. This behaves like Browserify's browser field.
package.globalBrowser
Global browser specific overwrites for module file resolution. These mapping take effect for all projects. Use sparingly.
package.steal
By default, any property on the package.steal object is passed to config. However, the following properties have special behavior:
package.steal.main
The moduleName of the initial module that should be loaded when the package is imported. For example:
When
my-moduleis imported,my-module@1.2.3#my-mainwill be the actual module name being imported. This path thatmy-mainwill be found depends on thedirectories.libsetting.package.steal.map
The map config works similar to the base map behavior. However, both the keys and values are converted to npm module names. The keys and values must:
./to map modules within the package like"./src/util", orpackageName#./modulePathto map direct dependencies of the package.package.steal.meta
The meta config works similar to the base meta behavior. However, the module names must:
./to add metadata to modules within the package like"./src/util", orpackageName#./modulePathto add metadata to direct dependencies of the package.Example:
package.steal.npmIgnore
Use npmIgnore to prevent package information from being loaded for specified dependencies in the
peerDependencies,devDependenciesordependencies. The following ignores a package.json'sdevDependenciesandcssify. But all other dependencies will be loaded:The following packages are ignored by default:
package.steal.npmDependencies
Like
npmIgnorebut affirmative. If used alone will only include the dependencies listed. If used in conjunction withnpmIgnoreacts as an override. For example the following config:Will load
onebut ignoretwo.When used in conjuction with
npmIgnore:Even though
npmIgnoreis set to ignore alldevDependenciesthe use ofnpmDependenciesacts as an override. The packageonewill be loaded, but nottwoorthree.package.steal.npmAlgorithm
Used to determine which algorithm is used to look up packages.
The default algorithm is
flat. We assume that you are using npm 3 or higher. See here more about the flat file structure of npm 3.If you are using npm 2 or pnpm, your dependencies of
node_moduleswill be nested. StealJS can handle the lookup by settingnpmAlgorithmtonested.package.steal.ignoreBrowser
Set to true to ignore browserfy's
browserandbrowserifyconfigurations.package.steal.directories
Set a folder to look for module's within your project. Only the
libdirectory can be specified.In the following setup,
my-project/my-utilswill be looked for inmy-project/src/my-utils.js:package.steal.configDependencies
Defines dependencies of your npm package. This is useful for loading modules, like extensions, that need to be initialized before the rest of your application is imported, e.g:
package.steal.plugins
Specifies packages that are used as plugins. These packages will be prefetched so that they're configuration will be applied before your app loads. An example is steal-css.