GithubHelp home page GithubHelp logo

modules-webmake's Introduction

modules-webmake - Bundle CommonJS modules for web browser

It's about organizing JavaScript code for browser same way as we do for Node.js. Modules rocks

If you're not that familiar with it (yet), see spec: http://www.commonjs.org/specs/modules/1.0/

Installation

$ npm install -g webmake

Usage

From the shell:

$ webmake path/to/program-module.js path/to/output.js

Program module is the main file in which you require needed stuff and make use of it.

Programmatically:

var webmake = require('webmake');
webmake('/path/to/program-module.js', function (err, source) {
	// Do whatever you need with generated source
});

Limitations

Application calculates dependencies by reading require paths from source code

Only plain written paths work

Following won't work:

require('./path/' + 'rest/of/path');
require(readFromVariable);
require(generatePath());

Supported are relative paths and outer packages paths

This will work:

require('./module-in-same-folder');
require('./module/path/deeper');
require('../../module-path-up'); // unless it doesn't go out of current package scope
require('other-package');
require('other-package/lib/some-module);

Absolute paths won't work (TODO)

require('/Users/foo/projects/awesome/my-module');

Commented requires or requires found in strings will be picked up (TODO)

Current dependency parsing is rudimentary, unfortunately following will be picked up:

// require('./well/i/dont/need/that')
var generatedCode = 'var s = require("used/somewhere/else");';

stay tuned, it will be fixed.

Different versions of same package will colide (TODO)

Let's say, required package A uses version 0.2 of package C and required package B uses version 0.3 of same package, it will most likely crash. Currently webmake will take C in version that was called first and will give it to both A and B.

TODO

  • Right dependency parsing (probably with help of UglifyJS)
  • Absolute path lookups
  • Support different package versions
  • Compiled version (no boilerplate code overhead, trimed requires)

modules-webmake's People

Contributors

medikoo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.