Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

gingermusketeer/commun.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

commun.js

A browser based commonjs module 1.0 compliant module loader.

why communjs

  • commonjs modules 1.0 compliance (same as node)
  • node_module support
    • need a module simply npm install and require it in your code
  • folder modules
    • either index.js or main script in package.json are used
  • cross browser
    • chrome -> Yes
    • firefox -> Yes
    • safari -> Yes
    • opera -> Yes
    • IE 9 -> Yes
    • IE 8 -> Yes
  • sandboxing modules from browser environment
    • var document = require('document');
  • simple syntax
    • A file is treated as a module and the only things exposed from the file is done explicitly through its exports
    • exports.awesomeFunctionality = ...

getting started

Download the source file (src/commun.js) and include it in your html as shown below

<script data-main="main.js" src="commun.js"></script>

where main.js is something like

var document = require('document');
var history = require('history');
var awesomeModule = require('something/like/this')

awesomeModule.be()

trying it out

git clone git@github.com:gingermusketeer/commun.js.git
cd commun.js
npm install
node serve
visit localhost:8080

Have a look at the source code in the example directory.

Contributing

In lieu of a formal style-guide, take care to maintain the existing coding style. Add Jasmine tests for any new or changed functionality. Lint and test your code using grunt.

Acknowledgements

acorn.js powers the parser used to detect syntax errors when a script fails to load.

License

Copyright (c) 2013 Max Brosnahan Licensed under the MIT license.

About

Browser based commonjs compliant module loader

Resources

License

Stars

Watchers

Forks

Packages