0.6.3 • Published 11 years ago
mundle v0.6.3
Mundlejs
Module bundler, cacher, and client-side loader Demonstration:
- Basics http://screencast.com/t/nOU53BRYUAX
- Plugins http://screencast.com/t/r1qtLvX44I Discussion: https://groups.google.com/forum/?fromgroups#!topic/nodejs/BQn0aH1qTpE
Installation
npm install mundle
Basic Usage
Server-side
serverRequire = require('mundle');
serverRequire.setBasePath('pathToMakeIntoTheClient-sideRoot');
serverRequire.listen(3000);
Server-side using Connect(/Express)
connect = require('connect');
mundle = require('mundle');
app = connect()
.use(mundle.connect('pathToMakeIntoTheClient-sideRoot')
.listen(3000);
Client-side
<script type='text/javascript' src='mundlejs/require.js'></script>
<script type='text/javascript'>
require('somePath',function(error,exportsFromSomePath){
console.log('Yayyy!');
};
</script>
- somePath can be 'moduleName@version' resolves to server-side basePath/mundles/moduleName/(version|default) './some/relative/path/to/file.js' resolves to server-side basePath/some/relative/path/to/file.js
Installing mundles
mundle install package
uses bower, so all bower packages are available here: http://sindresorhus.com/bower-components/
Defining mundles
Uses package.json with name, version, and main fields. main defaults to 'index.js' mundles are bower packages, so follow their instruction to use the centralized repo and the package dependency resolution: https://github.com/bower/bower
Plugins
plugin = require(plugin);
mundle.use(plugin);
or
plugin1 = require(plugin1);
plugin2 = require(plugin2);
mundle.use([plugin1, plugin2]);
- plugins allow you to pre-compile files before mundle attempts to parse them * e.g. Jade template files, for including pre-compiled client-side, or coffee
- plugins look like: {extensions: an array of file extensions, e.g. 'coffee', 'jade'}
- check my other repos for jade and coffeescript plugins
Tests
- To run automated tests cake test
- To run manual tests cd tests/manual node server.js * visit http://127.0.0.1:1337/ and observe console
Contribute
- Suggestions of how to make this more useful/robust/pluginable/available to more people very welcome
- Improve compatibility with Commonjs module specification
- Performance
- Bug reports
- Pull requests
- Can this be generalized, for example automatic optimization of spriting from css files?
- Plugins for processing files? e.g. compile jade templates
- Check out the issues for ideas on what you can implement
Coming soon
- https (might already be working ;) untested)
- more tests (especially client-side)
- cacheing
- client-side
- cdn
- have some ideas about cacheing to cdn's for really great performance
- check out the issues for more
Blog posts
- http://saleemabdulhamid.com/blog/2012/06/preparing-to-optimize-mundlejs - first benchmarks
- http://saleemabdulhamid.com/blog/2012/7/optimizing-mundlejs-cacheing-the-dependency-parse
- http://saleemabdulhamid.com/blog/2012/07/big-improvements
Copyright (C) 2012 Saleem Abdul Hamid Licensed under the GPL license