Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Created October 12, 2012 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-mapper/3880184 to your computer and use it in GitHub Desktop.
Save max-mapper/3880184 to your computer and use it in GitHub Desktop.
browserify/require notes

// sync loading var foo = require('modulename')

// authoring module.exports = function() {}

// json output format

{ "foo": { hash: "123ij1o35ij3o345ij", source: "function() { require('./modules/bar') }", requires: { "./modules/bar": "./bar" } }, "./bar": { // bar gets defined here } }

require('async-require')

// script output format require.define('modulename', function() { // something like json['modulename'].source() })

// async load var foo = require('foo')

setTimeout(function() { var bar = require('bar', function(err) { require('bar') }) }, 5000)

// various requires require('../../foo') require('foo') require('foo', cb) require('foo', false) require('foo', 'client-foo')

@Raynos
Copy link

Raynos commented Oct 12, 2012

Do we want to make require easier in the browser?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment