steal
Steal is a module loader that supports a wide variety of syntaxes and configuration options. It makes modular development, test and production workflows simple.
Steal is a module loader that supports a wide variety of syntaxes and configuration options. It makes modular development, test and production workflows simple.
There are four basic steps when using Steal:
Steal works slightly differently depending on how it is installed. There are three ways to install Steal:
npm basics
The following details how to use steal installed via npm to make a simple jQuery app.
Install
Next to your application's node_modules folder, create myapp.js and myapp.html:
Add the script tag
In myapp.html, add a script tag that that loads steal.js and points to the main entrypoint of your application. If main is not provided, main will be set to package.json's main.
Configure
Steal reads your application's package.json and all of its
dependencies
,peerDependencies
, anddevDependencies
recursively.Most configuration is done in the
steal
property of package.json. The special npm configuration options are listed here.The following package.json only loads the
dependencies
.If there are problems loading some of your dependencies, read how to configure them on the npm page.
Import modules and make stuff happen
In myapp.js, import your dependencies and write your app:
Importing in your app
From here using packages is the same as if you used npm, just import them into myapp.js and do what you need:
Download basics
The following details how to use steal installed via its download to make a basic jQuery app.
Install
Download Steal and unzip into your application's folder.
In your application's folder, create myapp.js, myapp.html and config.js. You should have something like:
Add the script tag
In myapp.html, add a script tag that that loads steal.js and points to the configPath and main entrypoint of your application.
Configure
config.js
is used to configure the behavior of your site's modules. For example, to load jQuery from a CDN:Import modules and make stuff happen
In myapp.js, import your dependencies and write your app:
Configuring
steal.loader
Once steal.js loads, its startup behavior is determined configuration values. Configuration values can be set in three ways:
Set on a
steal
object prior to loading steal.js like:Attributes on the steal.js script tag like:
Calling config. This technique is typically used in the configMain module.
If you are using npm, your app's package.json will be loaded automatically. Steal configuration happens in their
steal
properties:Typically, developers configure the main and configPath properties with attributes on the steal.js script tag like:
Setting configPath sets baseURL to the configPath's parent directory. This would load config.js prior to loading ../myapp.js.
When steal.js loads, it sets stealPath. stealPath sets default values for baseURL and configPath. If steal.js is in node_modules, configPath defaults to node_modules parent folder. So if you write:
This will load
../../package.json
before it loads../../myapp.js
.Writing Modules
Once you've loaded and configured steal's behavior, it's time to start writing and loading modules. Currently, ES6 syntax is supported in IE9+. ES6 syntax looks like:
Traceur Compiler is used and all of of its language features will work.
If you must support <IE8, use any of the other syntaxes.
Finally, steal supports [$less less] and [$css css] out of the box. Import, require, or steal them into your project by adding a "!" after the filename.