Skip to content

attrs/webmodules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webmodules

THIS PROJECT IS NO LONGER MAINTAINED

NPM Version NPM Downloads NPM Downloads NPM Downloads Join the chat at https://gitter.im/attrs/webmodules

Install

$ npm i -g webmodules

Usage

$ mkdir myapp
$ cd myapp
$ npm install jquery
  • public/index.html
<!DOCTYPE html>
<html>
<head>
  <script type="text/commonjs" data-src="app.js"></script>
  <script src="/node_modules/webmodules/runtime.js"></script>
</head>
<body>
  <div id="content"></div>
</body>
</html>
  • public/app.js
var $ = require('jquery');
var sub = require('./sub.js');

$(document).ready(function($) {
    $('#content').html('hello, ' + sub.value);
});
  • public/sub.js
exports.value = 'world';
  • launch
$ wpm up ./public

Programmatically

$ npm i webmodules express
  • lib/index.js
var webmodules = require('webmodules');
var express = require('express');

var app = express()
.use('/node_modules', webmodules.router())
.use('/', express.static('public'))
.listen(9000);
$ node lib

Examples

License

Licensed under the MIT License. See LICENSE for the full license text.