Code Monkey home page Code Monkey logo

aloe's Introduction

Aloe

Use npm in your AMD project.

Aloe could be seen as an alternative to browserify - it enables easy usage of npm modules in the browser. It was developed for use in projects that are already AMD and/or like AMD (!), but want to use npm as the package manager. The npm packages are (and should be) authored in CJS, but aloe lets you transparently mix npm's CJS modules and your project's AMD modules by wrapping CJS modules are in AMD at serve time.

With Aloe you can do the following in your frontend JavaScript projects:

  • use npm as the package manager
  • use a mixture of AMD/CJS modules in your project
  • link local modules - useful for development of modules, or for splitting your large app into multiple modules - each with it's own package.json - while keeping it in the same repo (or separate ones) - using npm link
  • generate an AMD build config that can be used to build all of the above as you would normally build your AMD project
  • use node builtin core modules in the browser (standard lib, like path, buffer, etc. and globals such as process, __dirname, etc. - all reusing browserify's node-browser-builtins)

Aloe is only intended for use in development. For production, aloe can export the AMD config npm modules to a dist/build directory - those files can then be served with your usual static server or optimized using and AMD optimizer, such as r.js. The aloe export feature could also be used for development by running it after each npm install, but that requires a slightly more involved configuration (see examples).

Usage

Start the server

aloe

Embed aloe's require.js+config into your HTML

<script data-main="app" src="http://localhost:4103/require.js"></script>

You can add your own AMD config as usual, you can configure the base URL anyway you want, etc. However, you can now require npm modules you've installed via npm install.

E.g.

npm install location-bar

And in your app.js

define(function (require) {

  var LocationBar = require("location-bar");

  var locationBar = new LocationBar();
  locationBar.update("/some/url");

});

Configuration

.aloerc

Linking

TODO

  • look into https://npmjs.org/package/browser-resolve
  • error handling
  • tests
  • --create should create a directory with index.html and app.js and package.json with some modules
  • writeup npm link
  • aloe config / aloe build / aloe export

aloe's People

Contributors

kidkarolis avatar

Watchers

 avatar  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.