├── test ├── withIndex │ └── index.js ├── foo │ ├── dep2.js │ └── dep.js ├── regressions │ ├── last-char-curly-brace.js │ └── a.js ├── index.html ├── coffee │ └── foo.coffee ├── module.js ├── expected-coffescript-sourcemap.json ├── expected-sourcemap.json └── test.js ├── .gitignore ├── .jshintignore ├── .travis.yml ├── .jshintrc ├── package.json ├── LICENSE ├── README.md └── index.js /test/withIndex/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 'works'; 2 | -------------------------------------------------------------------------------- /test/foo/dep2.js: -------------------------------------------------------------------------------- 1 | module.exports = exports = 'world'; 2 | -------------------------------------------------------------------------------- /test/regressions/last-char-curly-brace.js: -------------------------------------------------------------------------------- 1 | var a = require('./a'); 2 | console.log(a.foo()); -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/regressions/a.js: -------------------------------------------------------------------------------- 1 | /* jshint asi: true */ 2 | module.exports.foo = function () { 3 | "use strict"; 4 | return 'foo'; 5 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/compiled.js 2 | test/compiled-for-source-maps.js 3 | test/compiled-for-coffee-source-maps.js 4 | node_modules 5 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | test/compiled.js 3 | test/compiled-for-source-maps.js 4 | test/compiled-for-coffee-source-maps.js 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.8" 4 | - "0.10" 5 | before_install: 6 | - npm install -g npm@~1.4.6 7 | -------------------------------------------------------------------------------- /test/coffee/foo.coffee: -------------------------------------------------------------------------------- 1 | module.exports = exports = -> 2 | console.log 'YO' 3 | debugger 4 | console.log 'BRO' 5 | 6 | exports() 7 | -------------------------------------------------------------------------------- /test/foo/dep.js: -------------------------------------------------------------------------------- 1 | /*jshint debug: true*/ 2 | 'use strict'; 3 | 4 | exports = module.exports = { 5 | hello: 'world', 6 | test: function(){ 7 | debugger; 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /test/module.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var foo = require('./foo/dep'); 3 | var dep2 = require('./foo/dep2'); 4 | var withIndex = require('./withIndex'); 5 | var innersource = require('innersource'); 6 | 7 | exports = module.exports = { 8 | hello: foo.hello 9 | }; 10 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "noempty": true, 4 | "newcap": true, 5 | "eqeqeq": true, 6 | "eqnull": true, 7 | "undef": true, 8 | "devel": true, 9 | "node": true, 10 | "browser": true, 11 | "evil": false, 12 | "latedef": "func", 13 | "nonew": true, 14 | "trailing": true, 15 | "immed": true, 16 | "smarttabs": true, 17 | "strict": true, 18 | "predef": [ 19 | "before", 20 | "after", 21 | "describe", 22 | "require", 23 | "define", 24 | "it", 25 | "chai", 26 | "sinon" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/expected-coffescript-sourcemap.json: -------------------------------------------------------------------------------- 1 | "{\"version\":3,\"file\":\"generated.js\",\"sources\":[\"/Users/jpaul/workspace/requireify/node_modules/browserify/node_modules/browser-pack/_prelude.js\",\"/Users/jpaul/workspace/requireify/test/coffee/foo.coffee\"],\"names\":[],\"mappings\":\"AAAA;;;ACAA,IAAA,GAAA;;AAAA,CAAA,EAAiB,GAAX,CAAN,EAA2B;CACzB,CAAA,CAAA,CAAA,GAAO;CACP,UADA;CAEQ,EAAR,EAAA,EAAO,EAAP;CAHyB;;AAK3B,CALA,MAKA\",\"sourcesContent\":[\"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\\\"function\\\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error(\\\"Cannot find module '\\\"+o+\\\"'\\\")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\\\"function\\\"&&require;for(var o=0;o\\n console.log 'YO'\\n debugger\\n console.log 'BRO'\\n\\nexports()\\n\"]}" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "requireify", 3 | "version": "1.0.0", 4 | "description": "Browserify plugin to access all modules from browser console", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node test/test.js", 8 | "pretest": "npm run hint", 9 | "hint": "jshint --config .jshintrc ." 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/johnkpaul/requireify" 14 | }, 15 | "keywords": [ 16 | "browserify", 17 | "v2", 18 | "js", 19 | "plugin", 20 | "transform" 21 | ], 22 | "author": "John K. Paul", 23 | "license": "MIT", 24 | "dependencies": { 25 | "combine-source-map": "~0.2.0", 26 | "detective": "~4.2.0", 27 | "inline-source-map": "~0.2.5", 28 | "innersource": "0.0.2", 29 | "through": "~2.2.7" 30 | }, 31 | "devDependencies": { 32 | "jshint": "~2.1.11", 33 | "convert-source-map": "~0.2.6", 34 | "coffeeify": "~0.5.2", 35 | "browserify": ">=3.0.0" 36 | }, 37 | "peerDependencies": { 38 | "browserify": ">=3.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Licensed under the standard MIT license: 2 | 3 | Copyright 2013 Esa-Matti Suuronen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # requireify 2 | 3 | Browserify v3 transform to allow access to all modules from browser console 4 | 5 | [![Build Status](https://travis-ci.org/johnkpaul/requireify.png)](https://travis-ci.org/johnkpaul/requireify) 6 | 7 | ![Usage](https://dl.dropboxusercontent.com/u/21266325/requireify.gif) 8 | 9 | ## Usage 10 | 11 | Install requireify locally to your project: 12 | 13 | npm install requireify --save-dev 14 | 15 | 16 | Then use it as Browserify transform or global transform module: 17 | 18 | browserify --transform requireify main.js > bundle.js 19 | # Will parse files in node_modules, for more see https://github.com/substack/node-browserify/issues/566 20 | browserify --global-transform=requireify main.js > bundle.js 21 | 22 | 23 | 24 | ```javascript 25 | // /index.js 26 | exports = module.exports = { 27 | hello: 'world' 28 | }; 29 | 30 | // /foo/dep.js 31 | 32 | var dep = require('./foo/dep'); 33 | console.log(dep.hello); // world 34 | ``` 35 | 36 | Now, inside your browser console, you can look up every module on the global require 37 | 38 | >> var hello = require('/foo/dep').hello; 39 | >> console.log(hello); // world 40 | 41 | You can also include all libraries in the browser console that have been installed using npm and used in your browserify'd code. 42 | -------------------------------------------------------------------------------- /test/expected-sourcemap.json: -------------------------------------------------------------------------------- 1 | "{\"version\":3,\"file\":\"generated.js\",\"sources\":[\"/Users/jpaul/workspace/requireify/node_modules/browserify/node_modules/browser-pack/_prelude.js\",\"/Users/jpaul/workspace/requireify/node_modules/innersource/index.js\",\"/Users/jpaul/workspace/requireify/test/foo/dep.js\",\"/Users/jpaul/workspace/requireify/test/foo/dep2.js\",\"/Users/jpaul/workspace/requireify/test/module.js\",\"/Users/jpaul/workspace/requireify/test/withIndex/index.js\"],\"names\":[],\"mappings\":\"AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACTA;AACA;;;;;;;ACDA;AACA\",\"sourcesContent\":[\"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\\\"function\\\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error(\\\"Cannot find module '\\\"+o+\\\"'\\\")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\\\"function\\\"&&require;for(var o=0;o