• Stars
    star
    449
  • Rank 97,328 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 13 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LMD - JavaScript Module-Assembler for building better web applications ⚠️ Project is no longer supported ⚠️

LMD: Lazy Module Declaration Build Status NPM version Dependency Status

⚠️ Project is no longer supported

Please consider moving to webpack. As LMD uses CommonJS modules it should be straightforward.


New to LMD? See Getting Started, Wiki and examples

Why LMD? Why not AMD?

  • 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 can't access LMD-package, 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

What's on the board

  • All builders/loaders stuff
  • GUI for LMD (in development)
  • Build Analyzer (1-click code coverage, depends, startup perfomance)
  • Smart and simple CLI tool

Other features

  1. Default modules are CommonJS
  2. LMD does not create globals
  3. LMD is standalone, tiny and flexible (minimal only 288bytes!)
  4. Each function-module can be initialized/evaled on demand (lazy: true)
  5. LMD module is as easy to debug as normal JavaScript file
  6. Build system compresses JavaScript files using UglifyJs
  7. LMD module can define object via return or module.exports or exports as CommonJS Module
  8. Module can be wrapped automatically in builder so you can write your modules as node.js modules
  9. Starting from version 1.5.2 LMD can require off-package modules "async": true (see Asynchronous module require)
  10. From version 1.6.0 LMD can cache all in-package modules in localStorage "cache": true (see Local Storage cache)
  11. From version 1.6.2 LMD can include off-package css css: true and js-files js: true(for jsonp, cross-origin JS or non LMD modules)
  12. LMD package is possible to run as Web Worker or execute as Node.js script (see Web Worker and Node.js)
  13. LMD works in all modern browsers and in older IE
  14. 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)
  15. LMD can protect your code from 3-party modules (see Modules sandbox)
  16. Code Coverage? - Easy! (see Code coverage)
  17. Ready for production - lmd.js is 100% covered by unit tests see test/README.md for details
  18. SourceMap for all LMD modules (see Source map)
  19. Rich CLI interface

Installing

npm install lmd -g global is prefered for LMD CLI comands.

LMD Config file

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

Build LMD package from Console

lmd build your_buiild_name

See LMD CLI

Grunt integration and task

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

Special features

  • 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

Config extras

  • 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

Testing lmd builds

  • testing lmd build with mocha and mocha-phantomjs. See demo, code
  • code coverage with istanbul and testing lmd build with mocha and mocha-phantomjs See demo, report, code

Bash/zsh completion

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

Running tests

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

More Repositories

1

autopolyfiller

Autopolyfiller — Precise polyfills. This is like Autoprefixer, but for JavaScript polyfills.
JavaScript
552
star
2

relocating-to-berlin

Q&A about relocating to Berlin, Germany
271
star
3

jquery.notification

Webkit Notification API wrapper
JavaScript
154
star
4

node-mc

nmc – Midnight Commander written in React/Node stack.
JavaScript
140
star
5

b_

BEM class name formatter
JavaScript
103
star
6

gulp-autopolyfiller

Gulp plugin for autopolyfiller
JavaScript
53
star
7

html-tui

HTML to TUI (Text user interface) renderer. It is like TurboVision but in pure HTML, CSS and JavaScript
JavaScript
50
star
8

scalable-js-app

Scaleable JavaScript Application Architecture Example
JavaScript
49
star
9

rivets-backbone-adapter

Backbone.js adapter for Rivets.js data-bind with nested models and collections support
HTML
49
star
10

javascript-ecdc

JavaScript Elastic Cloud for Distributed Computing - framework for creating browser-based distributed computing applications based on Node.js
JavaScript
39
star
11

node-request-as-curl

It serializes http.ClientRequest as curl(1) command string
JavaScript
39
star
12

1css

1CSS - CSS dialect made for fun
JavaScript
27
star
13

grunt-autopolyfiller

Grunt plugin for autopolyfiller
JavaScript
25
star
14

phonegap-tumblr-reader

Simepe Tumblr Reader applicaiotn for Android, iOS and BlackBerry based on PhoneGap
JavaScript
14
star
15

event-source-chat

Simple chat based on EventSource SSE
JavaScript
13
star
16

talk-back-to-text-ui

React Europe Back to Text UI talk
HTML
9
star
17

dart-http

dart http server
9
star
18

lodash-template

_.template without full lodash source
JavaScript
6
star
19

ninjs

Ninja JavaScript Builder - JavaScript project builder without any extra global variables
JavaScript
6
star
20

image-ambilight

Ambilight effect on image
JavaScript
6
star
21

gitmodules-bower

.gitmodules to bower.json translator
JavaScript
5
star
22

grunt-lmd

It builds LMD
JavaScript
5
star
23

visual-dof-calc

Visual Depth of Field Calculator
JavaScript
4
star
24

shower-remote

Shower Remote - "Keynote Remote" for Shower presentation template
JavaScript
3
star
25

talk-better-js

Even Better JavaScript (ru)
CSS
2
star
26

talk-promises

Доклад Promise - это не больно!
JavaScript
2
star
27

talk-solid

SOLID - Курс по паттернам
JavaScript
2
star
28

node-jet

Jet - tiny, fast jQuery-style Node.js framwork
JavaScript
2
star
29

promise-attempt

Attempt tries to resolve promises
JavaScript
2
star
30

autopolyfiller-stable

Stable polyfills for Autopolyfiller
JavaScript
2
star
31

console-blame

It highlights and helps to find forgotten console.log calls in runtime
JavaScript
2
star
32

lmd-gui

GUI for LMD
JavaScript
1
star
33

pinterest-auto-layout-pdf-image-downloader

Pinterest board image downloader and auto-layout pdf generator
JavaScript
1
star
34

speed-dial

A minimalistic chrome extension implementing old good Opera's Speed Dial. Clean. Personalized. Performant. Flicker free.
HTML
1
star
35

talk-components-now

Components Now!
JavaScript
1
star
36

talk-404fest

Backbone в Яндексе
CSS
1
star
37

dart-star

jQuery-like Dart Library
1
star
38

azproduction.github.com

HTML
1
star
39

loader-test

loader-test
JavaScript
1
star
40

bravequest

Simple HTML-based RPG. Non Canvas. Only DOM, only hardcore!
JavaScript
1
star
41

node-reader-starred-grabber

Google Reader starred grabber for Node.js
JavaScript
1
star
42

jquery-mobile-markdown

Markdown for jQuery Mobile
1
star