Code Monkey home page Code Monkey logo

browserify-loader's Introduction

browserify-loader

A CommonJS Loader for browserify workflow [ES6 support].

What is browserify-loader

browserify-loader is another CommonJS loader for browserify workflow. With BL, You don’t need any tools like watchify, browserify-middleware to auto build and serve bundle *js in development env.

browserify-loader is similar with requirejs, but:

  • follow Modules/1.1.1 like Node
  • get rid of wrapper code like define()
  • be compatible all npm package and all bower components which support CommonJS. like underscore, backbone, jQuery and so on.

Getting start

install

Download browserify-loader with npm or bower:

$ npm install browserify-loader

Put browserify-loader.js in your page:

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
    <script type="text/javascript"
      src="node_modules/browserify-loader/browserify-loader.js"></script>
</body>
</html>

Then, browserify-loader will start to run for main file in your package.json file.

options

browserify-loader has two options to specify the main script or package location. and browserify-loader supports coffee-script.

    <script type="text/javascript"
        id="bl-script"
        main="backbone/app.js"
        package="backbone/"
        extensions="js json 6.js jsx"
        src="node_modules/browserify-loader/browserify-loader.js"></script>
  • main: the main entrance script like app.js in node app.js
  • package: the location where browserify-loader to load package.json, then get the main entrance from main property.
  • extensions: the enable extensions you want basing on your source code. browserify-loader now supports .js.6.js(ES6), json and jsx(for react fans).

main 's priority is higher the package 's.

example

Look into todomvc-in-bl , which is a demo project based on todomvc to show how to use browserify-loader.

API

define

The internal wrapper API.

define.registerExtension

Register extension to browserify-loader, like:

var to5Transform = require('6to5/lib/6to5/transformation/transform')

define.registerExtension('jsx', function(script) {
  return to5Transform(script, {modules: "common"}).code
})

define.performance

browserify-loader's performance is important, and it is not ideal now yet!

browserify-loader provide a method to get its performance: define.performance()

Just think if there is no browserify-loader, where performance cost come from:

  • script load time

and then thinking cost in browserify-loader:

  • xhr loading time, roughly equals script load time

  • define time, concat code, insert script tag and so on

  • analysis module's dependences

  • resolve dependences' uri, include get package.json recursively

Update

0.5.2

  • hotfix

0.5.1

  • rewrite in es6

0.5.0

  • support ES6!
  • remove support coffee-script

0.4.2

  • improve for friendly debuging.

0.4.0

  • add registerExtension API
  • support jsx and json

0.3.0

  • use ES6's Promise instead of rsvp and eventemitter

0.2.0

  • support coffee-script

browserify-loader's People

Contributors

island205 avatar weakish avatar

Stargazers

erbao avatar

Watchers

James Cloos 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.