rqjs
rqjs
is a minimum AMD, CMD module loader for Javascript.
For now it just implement basic functions to keep minimum size.
Intallation
Use yarn to install rqjs
:
$ yarn add rqjs
Example
You can define a module by import es module of rqjs
:
; rqjs
Or you can define a module with dependencies:
; rqjs
Then you can execute a function by:
; rqjs
You can load rqjs.min.js
in a HTML page:
Then rqjs
will be mounted on global
Object, which is window
object in browser.
And you can get it from global environment in your code without import:
rqjs;rqjs
Finally, you can import modules manually:
const id = "moduleA"rqjsrqjs;
Interface
define(id, deps, def)
defines a module with unique identify. The id
argument is unique identify of module. deps
is string array type module's dependencies. And def
is the definition function of module. When function excuted, all dependencies would be injected into arguments of the definition function in order.