New to LMD? See Getting Started, Wiki and examples
- Modules are CommonJS
- Actually LMD can work with any JavaScript modules
- There is no define wrapper!
- You can use node modules without dirty hacks like
typeof exports ? :
- You can use strings as string without any "template" plugins
- You can use JSON file as Object
- Total and honest isolation
- LMD package is fully-zero-isolated from globals (globals cant access LMD-pacakge, but LMD can)
- Modules are isolated from LMD and from each module
- Modules can be sandboxed (3-party modules, can exports only)
- Plugins are isolated from LMD and from each module
- Lazy interpretation and load
- LMD can load off-package modules (all loaders can do it =)
- It can interpret(eval) modules when they are required
- List of depends are located in separate .json file
- Well... list of 2 deps in file are ok, but 5+ are headache
- Module is isolated from file system
- You have to edit only 1 file if module path changes
- Possible to use dynamic require()
- Config inheritance
- Easy to setup development, testing and production builds
- Build watcher
- Watcher detects changes in your files and performs rebuild
- Flexible source
- Minimal only 288bytes
- High optimized own code
- LMD builder performs build-time optimisations
- Integrated code-coverage and source analytics tool
- Its easy to enable believe me!
- No extra servers or movements are required for off-package modules Code-Coverage
- Transparent localStorage cache
- Change config and html a bit and voila!
- require() is not overloaded
- Overloaded require is the way to mess in source
- require.css() for css
- require.js() for js (non LMD-modules)
- require.async() for async LMD-modules (objects, strings, modules)
- More
- Can load CSS
- Can work with Node.js and Worker environment
- All builders/loaders stuff bla-bla-bla
- Build Analyzer (1-click code coverage, depends, startup perfomance)
- Smart and simple CLI tool
- GUI for LMD (in development)
- Modules are similar to AMD: there is a require, but no define
- LMD does not create globals
- LMD is standalone, tiny and flexible (minimal only 288bytes!)
- Each function-module can be initialized/evaled on demand (
lazy: true
) - LMD module is as easy to debug as normal JavaScript file
- Build system compresses JavaScript files using UglifyJs
- LMD module can define object via
return
ormodule.exports
orexports
as CommonJS Module - Module can be wrapped automatically in builder so you can write your modules as node.js modules
- Starting from version 1.5.2 LMD can require off-package modules
"async": true
(see Asynchronous module require) - From version 1.6.0 LMD can cache all in-package modules in localStorage
"cache": true
(see Local Storage cache) - From version 1.6.2 LMD can include off-package css
css: true
and js-filesjs: true
(for jsonp, cross-origin JS or non LMD modules) - LMD package is possible to run as Web Worker or execute as Node.js script (see Web Worker and Node.js)
- LMD works in all modern browsers and in older IE
- LMD can convert non-LMD modules to LMD to use jquery or any other as in-package LMD module (see LMD module form third-party modules)
- LMD can protect your code from 3-party modules (see Modules sandbox)
- Code Coverage? - Easy! (see Code coverage)
- Ready for production -
lmd.js
is 100% covered by unit tests see test/README.md for details - SourceMap for all LMD modules (see Source map)
- Reach CLI interface
npm install lmd -g
global is prefered for LMD CLI comands.
Minimal
{
"root": "../modules/",
"output": "../module.lmd.js", // Path are relative to the root parameter
"modules": {
"*": "*.js" // use wildcards or specify regex string to grep
}
}
See LMD Config for more information
Note
- You can extend config file with another using
"extends": "path/to/file.lmd.json"
parameter - You can also specify module depends by adding
"depends"
options see Modules dependencies
lmd build your_buiild_name
See LMD CLI
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-lmd
Then add this line to your project's grunt.js
gruntfile:
grunt.loadNpmTasks('grunt-lmd');
See grunt-lmd for details
async
- Providesrequire.async()
function. if modules uses off-package module set this to true. See demo, codeasync_plain
- enables async require of both plain and function-modulesasync_plainonly
- if you are using only plain modules enable that flag instead ofasync_plain
. See demo, codepreload
- this plugins is simmilar toasync
, it only caches modules without executing them. See demo, codepreload_plain
- same asasync_plain
async_plainonly
- same asasync_plainonly
cache
- stores all application lmd itself + all modules in localStorage this flag will force all modules to be lazy. See demo, codecache_async
- enables localStorage cache forrequire.async()
. See demo, code
js
- if you are going to load non LMD javascript modulesrequire.js()
set this flag to true. See demo, codecss
- enables css-loader featurerequire.css()
. See demo, codeimage
- enables image-loader featurerequire.image()
. See demo, code
worker
- set true if LMD package will run as workernode
- set true if LMD package will run as Node.js script. See demo, codeie
- enabled by default set false if script will run only in modern browsersopera_mobile
- set true if LMD package will run in Opera Mobilefile_protocol
- set to true if LMD package itself or it parts will be loaded usingfile://
protocol
race
- set true if you are performing simultaneous loading of the same resourcesparallel
- enables simultaneous loadingrequire.js([a, b, c], ..)
resources will be executed in load order! And passed to callback in list order. See demo, codepromise
- enables promise interface for all loadersrequire.js('a.js').then()
. See demo, code
shortcuts
- enables shortcuts in LMD package. See demo, code (promise example uses shortcuts)amd
- enables AMD RequreJS modules in LMD package. See demo, code
stats
- enablesrequire.stats()
function - every module require, load, eval, call statistics. See demo, codestats_coverage
- enables code coverage for all in-package modules, you can use list of module names to cover only modules in that list. See demo, codestats_coverage_async
- enables code coverage for all off-package function-modules for that option you can NOT use list of off-package module names. This options is VERY HEAVY +50Kb sources. Each async LMD module will be parsed and patched on the client - it may take A LOT of timestats_sendto
- enablesrequire.stats.sendTo(host[, reportName])
function. It POSTs stats&coverage report to specified stats server
- glob - you can specify glob pattern (eg
"${name}": "js/*.js"
) to match multiply files. See demo, code - interpolation - you can use templates in your config string values to make your life easier. See demo, code
- sandbox - some of your modules can be in the "sandbox". They cant require, but can provide some resources. See demo, code
- optimize - optimisations of LMD source(not your project files) without minification/packing. See Optimisations section of LMD Plugins overview wiki page. See demo, code
- adaptation - using any JavaScripts as modules. See Wiki page Adopting modules. See demo, code
- bundles - a way to split your application into separete parts. See demo, code
- styles - css builder for you bundles. See demo, code
- lmdjs_configs - you can write config files in JavaScript. See demo, code
- multi_modules - using jQuery or Backbone with plugins? This feature is for you. See demo, code
- ignore_module - ignore module from build, can be used with glob to ignore some modules. See demo, code
- mixins - you can mix your build configs (eg
lmd build index+ru+dev
) to create your special builds. See demo, code - depends - your modules can have own depends. You can notify LMD by adding global "depends" paramenter or specify "depends" for each module. See demo, code
- extends - your configs can inherit other configs (eg development extends production). See demo, code
Installation lmd completion >> ~/.bashrc
(or ~/.zshrc
). Do not forget to restart shell.
Other ways
- You can add
. <(lmd completion)
to your rc file - Or, maybe:
lmd completion > /usr/local/etc/bash_completion.d/lmd
phantomjs
is required to run test via npm test
see test for details
--
LMD is developing with help of these people
If you like LMD - โ
it via npm star lmd