In addition to a collection of plugins,StealJSis comprised of two main components:
steal
:an extensible, universal module loader.steal-tools
:utilities for building, transforming, and exporting module formats.
This is thesteal
repository. For thetools
,seehttps://github /stealjs/steal-tools.
steal
is unique because it can load JavaScript modules defined in ES6, AMD, and CommonJS formats (unlike most other module loaders, which only support one of these formats at a time).
In JavaScript, the word "modules" refers to small units of independent, reusable code. They are the foundation of many JavaScript design patterns, and can look like this in ES6:
exportfunctionhello(){
console.log('hello');
}
exportfunctiongoodbye(){
console.log('goodbye');
}
Or like this in AMD:
define([],function(){
return{
hello:function(){
console.log('hello');
},
goodbye:function(){
console.log('goodbye');
}
};
});
Or like this CommonJS:
functionhello(){
console.log('hello');
}
functiongoodbye(){
console.log('goodbye');
}
module.exports={
hello:hello,
goodbye:goodbye
}
All of these formats are supported bysteal
,so you can mix and match modules in your project:
// ES6
import{hello,goodbye}from"greetings";
// AMD
define(["greetings"],function(greetings){...});
// CommonJS
varhello=require('greetings').hello;
vargoodbye=require('greetings').goodbye;
Additionally, plugins make it possible to load ANY module type you might come up with, such as Less or CSS. Anyone can write a plugin forsteal
to extend it's core module-loading functionality.
The StealJS organization maintains popular plugins that extend and enhance the module-loading capabilities ofsteal
(and, subsequently,steal-tools
) such as:
For example, the Less plugin allows Less files to be loaded similarly to JavaScript modules:
// ES6
import"style.less";
// AMD
define(["style.less"],function(){...});
// CommonJS
require("style.less");
// steal
steal("style.less")
Looking to create a plugin for another format? SeeWriting Plugins.
For more information on StealJS, visitStealJS.
For information on contributing and developing, see theContributing Guide on StealJS.