Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

one

Package Overview
Dependencies
Maintainers
1
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

one - npm Package Compare versions

Comparing version 1.8.2 to 2.0.0

lib/aliases.js

35

lib/dependencies.js

@@ -5,4 +5,3 @@ var path = require('path'),

manifest = require('./manifest'),
installDict = Object.keys(require('./install_dict')),
excludeds = require('./excludeds'),
pkg;

@@ -14,23 +13,6 @@

function nodeCorePackages(pkg, callback){
readdir( path.join(pkg.wd, 'node_modules'), function(error, files){
if(error){
callback([]);
return;
}
callback(files.filter(function(el){
return installDict.indexOf(el) > -1;
}));
});
}
function dependencies(parent, options, callback){
var deps = [],
declaredDepObj = parent.manifest.dependencies,
exclude = excludeds(parent, options),
declaredDepList,

@@ -41,13 +23,6 @@ next;

declaredDepList = Object.keys(declaredDepObj).filter(function(name){
return BLACK_LIST.indexOf(name) == -1 && ( !options.exclude || options.exclude.indexOf(name) == -1 );
return BLACK_LIST.indexOf(name) == -1 && ( exclude.indexOf(name) == -1 );
});
}
nodeCorePackages(parent, function(installedNodeCorePackages){
if(installedNodeCorePackages.length){
!declaredDepList && ( declaredDepList = [] );
declaredDepList = declaredDepList.concat(installedNodeCorePackages);
}
if(!declaredDepList || !declaredDepList.length){

@@ -97,8 +72,4 @@ callback(undefined, deps);

})(0);
});
};
module.exports = dependencies;

@@ -1,35 +0,86 @@

var genpkg = require('genpkg'),
path = require('path'),
fs = require('fs'),
var path = require('path'),
fs = require('fs'),
puts = require('util').puts,
each = require('functools').each.async,
id = require('./id'),
templating = require('./templating'),
pkg = require('./package'),
templating = require('./templating'),
logging = require('./logging'),
server = require('./server'),
installDict = require('./install_dict'),
logging = require('./logging'),
server = require('./server'),
targets = require('./targets'),
manifest = require('./manifest'),
dependencies = require('./dependencies'),
pkg = require('./package'),
modules = require('./modules'),
manifest = require('./manifest'),
npmignore = require('./npmignore');
npmignore = require('./npmignore');
var slice = Array.prototype.slice;
function build(manifestPath, buildOptions, callback){
module.exports = function(){
return require('./chaining').apply(null, arguments);
};
var pkgOptions = {
'manifestPath': manifestPath
};
module.exports.main = main;
module.exports.build = build;
module.exports.dependencies = require('./dependencies');
module.exports.id = require('./id');
module.exports.pkg = pkg;
module.exports.npmignore = npmignore;
module.exports.manifest = manifest;
module.exports.modules = require('./modules');
module.exports.logging = logging;
module.exports.quiet = quiet;
module.exports.publish = publish;
module.exports.save = save;
module.exports.targets = targets;
module.exports.templating = templating;
module.exports.verbose = verbose;
module.exports.verbosity = verbosity;
function build(pkg, buildOptions, callback){
templating(pkg, buildOptions, callback);
}
function buildAndSave(pkg, options, callback){
build(pkg, options, function(error, bundle){
if(error) return callback(error);
var output = bundle['[stdout]'];
var filenames = Object.keys(bundle).filter(function(filename){
return filename != '[stdout]';
});
function iter(filename, _, _,callback){
logging.info('Saving %s', filename);
save(filename, bundle[filename], callback);
}
each(iter, filenames, function(error){
if(error) return callback(error);
if(output){
puts(output);
};
callback();
});
});
}
function main(manifestPath, buildOptions, callback){
var pkgOptions = { manifestPath: manifestPath };
readNPMIgnore(pkgOptions, buildOptions, function(error, toIgnore){
toIgnore && ( pkgOptions.ignore = toIgnore );
templating(pkgOptions, buildOptions, callback);
pkg(pkgOptions, buildOptions, function(error, loadedPkg){
if(error) return callback(error);
buildOptions.save = targets(loadedPkg, pkgOptions, buildOptions);
buildAndSave(loadedPkg, buildOptions, callback);
});
});
}

@@ -63,3 +114,4 @@

function save(target, content, callback){
logging.debug('Saving output into '+target);
logging.debug('Saving output into ' + target);
fs.writeFile(target, content, function(error) {

@@ -87,41 +139,2 @@ if(error) {

function setupNodeModules(/* modules */){
var pkgs = slice.call(arguments, 0, arguments.length-1),
callback = arguments[arguments.length - 1],
len = pkgs.length;
var pkgName, pkgURI, next;
(function iter(i, error){
if(i>=len || error){
callback(error);
return;
}
pkgName = pkgs[i];
pkgURI = installDict[pkgName];
if(!pkgURI){
logging.error('Unknown package "%s" ', pkgName);
callback(new Error('Unknown package "%s"', pkgName));
return;
}
next = iter.bind(undefined, i+1);
genpkg.pkg({ 'uri':pkgURI }, function(error, pkg){
if(error){
throw error;
}
pkg.target = path.join('node_modules', pkg.manifest.name);
genpkg.save(pkg, next);
});
})(0);
}
function verbose(){

@@ -134,19 +147,1 @@ logging.setLevel('TRACE');

}
module.exports = {
'build': build,
'dependencies': dependencies,
'id': id,
'pkg': pkg,
'npmignore': npmignore,
'manifest': manifest,
'modules': modules,
'logging': logging,
'quiet': quiet,
'publish': publish,
'save': save,
'setupNodeModules': setupNodeModules,
'templating': templating,
'verbose': verbose,
'verbosity': verbosity
};

@@ -154,3 +154,2 @@ var functools = require('functools'),

if(pkg.dirs && pkg.dirs.lib){
base = join(pkg.dirs.lib);

@@ -157,0 +156,0 @@ dirs.push(base);

@@ -22,3 +22,3 @@ var path = require('path'),

var struct = {
'id' : context.hasOwnProperty('id') && context.id != undefined ? context.id : module.exports.id(),
'id' : context.manifest.name,
'dependencies' : undefined,

@@ -80,3 +80,2 @@ 'dirs' : context.manifest.directories || {},

var i = modules.length, m;

@@ -128,7 +127,5 @@

function content(pkg, options, callback){
logging.debug('Loading the package "%s"', pkg.manifest.name);
compose.async(loadDependencies, loadModules, setMainModule)({ 'pkg': pkg, 'options': options }, function(error){
if(error){

@@ -166,7 +163,7 @@ callback(error);

'wd': path.normalize(path.dirname(manifestPath)),
'parents': options.parents, 'parent': options.parent
'parents': options.parents,
'parent': options.parent
};
construct(constructOptions, function(error, pkgobj){
if(error){

@@ -173,0 +170,0 @@ callback(error);

var boxcars = require("boxcars"),
config = require("../config"),
render = require('./render');
module.exports = coll;
function templateName(filename){

@@ -14,12 +14,8 @@ return filename

function template(files, name){
var args = Array.prototype.slice.call(arguments),
views = args.length > 3 ? args[2] : undefined,
partials = args.length > 4 ? args[3] : undefined,
callback = args[ args.length - 1 ];
files(function(error, buffers){
if(error){

@@ -36,5 +32,3 @@ callback(error);

render(buffers[name], views, partials, callback);
});
}

@@ -50,9 +44,5 @@

while( i --> 0 ){
filename = arguments[i];
name = templateName(filename);
param[ name ] = config.TEMPLATES_DIR + '/' + filename;
}

@@ -62,6 +52,5 @@

var key;
for(key in param){
files [ key ] = template.bind(undefined, files, key);
files[ key ] = template.bind(undefined, files, key);
}

@@ -71,3 +60,1 @@

}
module.exports = coll;

@@ -7,2 +7,3 @@ var readFile = require('fs').readFile,

objectName = require('../object_name'),
buildTree = require('../build_tree'),

@@ -15,12 +16,25 @@ npmpackage = require('./package'),

function dynamic(pkg, options, callback){
logging.info('Rendering %s', pkg.name);
var treeName = objectName(pkg.name),
tree = flattenPkgTree(pkg).sort(sort);
var bundleName = objectName(pkg.name),
trees = buildTree(pkg, options);
options.includeProcess = !options.noprocess;
map(renderPackageTree.bind(undefined, options, bundleName), trees, function(error, output){
logging.info('All packages has been built. Rendering wrapper now...');
map( npmpackage.bind(undefined, treeName, options), tree, function(error, packages){
var mainTarget = options.save[pkg.name].to;
wrapper(pkg, bundleName, output[mainTarget], options, function(error, rpl){
if(error) return callback(error);
output[mainTarget] = rpl;
callback(undefined, output);
});
});
}
function renderPackageTree(options, bundleName, tree, callback){
map(npmpackage.bind(undefined, bundleName, options), tree, function(error, packages){
if(error){

@@ -31,15 +45,7 @@ callback(error);

logging.info('All packages has been built. Rendering the output now...');
wrapper(treeName, packages.join('\n\n\n\n'), options, callback);
callback(undefined, packages.join('\n\n'));
});
}
function sort(a, b){
return a.name.localeCompare(b.name);
}
module.exports = dynamic;
module.exports.flattenPkgTree = flattenPkgTree;
var juxt = require('functools').juxt.async,
logging = require('../../logging'),
env = require('../env'),
version = require('../version'),
templates = require('./templates'),
oneJSPath = require('./path');
oneJSPath = require('./path'),
oneJSConsole = require('./console'),
oneJSProcess = require('./process');
function library(options, callback){

@@ -22,8 +16,6 @@

versions : '{}',
env : env(options),
sandbox_console : options.sandboxConsole,
include_process : options.includeProcess
env : env(options)
};
juxt({ 'path': oneJSPath, 'process': oneJSProcess, 'console': oneJSConsole })(options, function(error, partials){
juxt({ 'path': oneJSPath })(options, function(error, partials){

@@ -30,0 +22,0 @@ if(error){

@@ -5,12 +5,11 @@ var logging = require('../../logging'),

module.exports = function oneJSModule(pkg, treeName, options, module, callback){
logging.debug('Building module "'+module.id+'"');
var view = {
'treeName' : treeName,
'parentId' : pkg.id,
'id' : module.id,
'sandbox_console' : options.sandboxConsole,
'include_process' : options.includeProcess,
'content' : module.content
'treeName' : treeName,
'parentId' : pkg.id,
'id' : module.id,
'content' : module.content,
'debug' : options.debug,
'contentWithSourceURLs' : JSON.stringify(module.content + '//@ sourceURL=' + module.path)
};

@@ -17,0 +16,0 @@

var map = require('functools').map.async,
logging = require('../../logging'),
templates = require('./templates'),
oneJSModule = require('./module');

@@ -14,3 +11,3 @@

function parentIds(pkg){
return pkg.parents.map(function(el){ return el.id; }).join(', ');
return pkg.parents.map(function(el){ return '"'+el.id+'"'; }).join(', ');
}

@@ -33,4 +30,3 @@

map( oneJSModule.bind(undefined, pkg, treeName, options), modules, function(error, modules){
map(oneJSModule.bind(undefined, pkg, treeName, options), modules, function(error, modules){
if(error) {

@@ -42,7 +38,5 @@ callback(error);

view.modules = modules.join('\n\n');
templates['package'](view, callback);
});
};

@@ -7,6 +7,4 @@ var coll = require('../coll');

'dynamic/module.js',
'dynamic/console.js',
'dynamic/library.js',
'dynamic/path.js',
'dynamic/process.js'
'dynamic/require.js',
'dynamic/registry.js'
);

@@ -1,19 +0,18 @@

var logging = require('../../logging'),
library = require('./library'),
templates = require('./templates');
var logging = require('../../logging'),
ownrequire = require('./require'),
registry = require('./registry'),
templates = require('./templates'),
ties = require('../../ties'),
aliases = require('../../aliases');
function ties(options){
function renderAliases(aliases){
return JSON.stringify(aliases);
};
if(!options.tie){
return undefined;
}
function renderTies(ties){
var output = '{',
key, comma = '';
var output = '{', key,
i = options.tie.length,
comma = '',
tie;
while( i -- ){
tie = options.tie[i];
output += comma + '"'+ ( tie.pkg || tie.module ) + '": ' + ( tie.obj || tie.to );
for(key in ties){
output += comma + '"' + key + '": ' + ties[key];
comma = ', ';

@@ -27,16 +26,14 @@ }

function wrapper(treeName, packages, options, callback){
function wrapper(pkg, treeName, renderedPackages, options, callback){
logging.trace('Rendering wrapper template...');
var partials = {},
views = {
'name' : treeName,
'debug' : options.debug,
'ties' : ties(options),
'sandbox_console' : options.sandboxConsole,
'include_process' : options.includeProcess
var partials = {},
views = {
'name' : treeName,
'debug' : options.debug,
'ties' : renderTies(ties(pkg, options)),
'aliases' : renderAliases(aliases(pkg, options))
};
library(options, function(error, renderedLibrary){
ownrequire(options, function(error, renderedRequire){
if(error){

@@ -47,7 +44,16 @@ callback(error);

views.packages = packages;
views.library = renderedLibrary;
registry(options, function(error, renderedRegistry){
if(error){
callback(error);
return;
}
templates.wrapper(views, callback);
views.packages = renderedPackages;
views.require = renderedRequire;
views.registry = renderedRegistry;
options.hasAsync && (views.async = JSON.stringify(options.async));
templates.wrapper(views, callback);
});
});

@@ -54,0 +60,0 @@ }

@@ -9,19 +9,22 @@ var pkg = require('../package'),

function main(pkgOptions, buildOptions, callback){
function main(pkg, options, callback){
var layout = options.plain ? plain : dynamic;
var layout = buildOptions.plain ? plain : dynamic;
var async = {},
hasAsync = false;
pkg(pkgOptions, buildOptions, function(error, loadedPkg){
if(error){
callback(error);
return;
var key;
for(key in options.save){
if(key != pkg.name){
async[key] = options.save[key].url;
hasAsync = true;
}
}
layout(loadedPkg, buildOptions, function(error, sourceCode){
callback(error, sourceCode, pkg);
});
options.async = async;
options.hasAsync = hasAsync;
layout(pkg, options, function(error, sourceCode){
callback(error, sourceCode, pkg);
});
}

@@ -28,0 +31,0 @@

@@ -8,5 +8,16 @@ var logging = require('../../logging'),

templates.wrapper({ 'name': objectName(pkg.name), 'content': pkg.modules[0].content }, callback);
templates.wrapper({ 'name': objectName(pkg.name), 'content': pkg.modules[0].content }, function(error, bf){
if(error){
callback(error);
return;
}
var ret = {};
ret[options.save[pkg.name].to] = bf;
callback(undefined, ret);
});
}
module.exports = plain;

@@ -1,9 +0,11 @@

var mustache = require('mustache');
var hogan = require('hogan.js');
function render(buffer, views, partials, callback){
module.exports = render;
function render(template, views, partials, callback){
var output;
try {
output = mustache.to_html(buffer, views, partials);
template = hogan.compile(template);
output = template.render(views, partials);
} catch (mustacheError) {

@@ -15,5 +17,2 @@ callback(mustacheError);

callback(undefined, output);
}
module.exports = render;
{
"name":"one",
"version":"1.8.2",
"version":"2.0.0",
"description":"Transform NodeJS packages into single stand-alone script files.",

@@ -13,9 +13,7 @@ "author":"Azer Koculu <azer@kodfabrik.com>",

"dependencies":{
"boxcars":"0.x",
"functools":"1.x",
"optimist":"0.x",
"combiner":"1.2.x",
"mustache":"0.4.x",
"hogan.js":"2.x",
"log4js":"0.4.1",
"genpkg":"0.x",
"boxcars":"0.x"

@@ -22,0 +20,0 @@ },

OneJS is a command-line utility for converting CommonJS packages to single, stand-alone JavaScript
files that can be run on web browsers.
Version: v2.0
# MOTIVATION
* **Reusability** OneJS lets developers code JavaScript for one platform and run everywhere, without requiring any additional effort.
* **Elegant Modularization** Modules and packages specs of CommonJS are what web apps exactly needs: a very well designed way to structure JavaScript code.
* **Elegant Modularization** Modules and packages specs of CommonJS are what web apps exactly needs: a well designed way to structure your source code.
* **NPM** OneJS moves the revolution of NPM one step forward and makes it available for client-side projects!

@@ -13,183 +15,316 @@ * **No Spaghetti Code** No awkward headers, no framework-specific definitions.

![](http://oi41.tinypic.com/aw2us3.jpg)
![](https://dl.dropbox.com/s/e1ob30ypqfjukvl/alma_1.jpg)
### Examples
* See the example project included in this repository
* MultiplayerChess.com ([Source Code](https://github.com/azer/multiplayerchess.com/tree/master/frontend) - [Output](http://multiplayerchess.com/mpc.js) )
* [ExpressJS built by OneJS](https://gist.github.com/2415048)
* [OneJS built by OneJS](https://gist.github.com/2998719)
# DOCUMENTATION
* [Install](#install)
* [First Steps](#first-steps)
* [Advanced Usage](#advanced-usage)
* [Saving Multiple Files](#multiple)
* [Package Aliases](#alias)
* [Accessing Global Browser Variables](#global-vars)
* [Excluding Packages](#exclude)
* [Filtering Modules](#filter)
* [API Reference](#api)
* [Command-Line API](#cli)
* [NodeJS API](#nodejs)
* [package.json](#packagejson)
* [Examples](#examples)
* [Troubleshooting](#troubleshooting)
* [Testing](#testing)
# INSTALL
<a name="install"></a>
## Install
```bash
$ npm install one
$ npm install -g one
```
# MANUAL
<a name="first-steps"></a>
# First Steps
## First Steps
The quickest way of giving OneJS a try is to run "onejs build package.json" command in a project folder. It'll walk through all the directories, find
JavaScript files in the "lib" folder (if exists, and by considering .npmignore), and produce an output that can be run by any web browser and NodeJS, as well.
OneJS walks the modules and dependencies defined by package.json files. To create your bundle, just go a project directory and type `onejs build` command:
Bundle files produced by OneJS consist of a CommonJS implementation and the throughout package tree wrapped by [OneJS' templates](https://github.com/azer/onejs/tree/master/templates/dynamic).
And the produced output will be unobtrusive. Which means, your project will not conflict with any other JavaScript on the page that is embedded.
Once you produce the output, as you expect, it needs to be included by an HTML page, like the below example;
```bash
$ one build hello-world/package.json output.js
$ cat > index.html
<html>
<script src="output.js"></script>
<script>helloWorld();</script>
</html>
```
$ onejs build package.json bundle.js
```
### Experimenting the Bundle Script
You may notice a function named `helloWorld` was called. That's what starts running your program by requiring the `main` module of the project.
Besides of that `helloWorld` refers to the main module, it also exports some utilities that can be useful. See following for an example;
The output OneJS generates can be used by NodeJS, too. It's the easiest way of making sure if the output works or not.
```js
> helloWorld.require('./module');
[object ./module.js]
> helloWorld.require('dependency');
[object node_modules/dependency]
```
> var exampleProject = require('./bundle');
> exampleProject.main() // calls main module, returns its exports
> exampleProject.require('./b') // each package object has a require method available for external calls
```
In the case what you need is to try it in web browsers, onejs has a "server" option that'll publish the source code at `localhost:1338` let you debug the output with Firebug Lite easily;
In addition to command-line API, there are two more ways to configure build options. You can have the configuration in a package.json manfest;
```json
{
"name": "hello-world",
"version": "1.0.0",
"directories": {
"lib": "lib"
},
"web": {
"save": "bundle.js",
"alias": {
"crypto": "crypto-browserify"
},
"tie": {
"jquery": "window.jQuery"
}
}
}
```
$ ../bin/onejs server example-project/package.json
```
### Using the NodeJS Core Library
Or, you can write your own build script using OneJS' [chaining API](https://github.com/azer/onejs/blob/master/lib/chaining.js):
Many modules of the core NodeJS library is able to be used by web projects, as well. OneJS has an 'install' command that converts demanded remote NodeJS module to a package on the fly:
```js
// build.js
var one = require('../../../lib');
```javascript
> onejs install assert path url
one('./package.json')
.alias('crypto', 'crypto-browserify')
.tie('pi', 'Math.PI')
.tie('json', 'JSON')
.exclude('underscore')
.filter(/^build\.js$/)
.filter(/^bundle\.js$/)
.save('bundle.js');
```
The reference of available modules that you can install: https://github.com/azer/onejs/blob/master/lib/install_dict.js
<a name="advanced-usage"></a>
## Advanced Usage
## Process
<a name="multiple"></a>
### Saving Multiple Files
OneJS includes a simple emulation of [NodeJS' process](http://nodejs.org/api/process.html). (Pass --noprocess if you don't need it)
Specified dependencies (including their subdependencies) can be splitted to different files via `package.json` manifest.
```javascript
> exampleProject.require('dependency'), exampleProject.require('./b');
> exampleProject.lib.process.stdout.write("Hello World");
> exampleProject.stdout();
"Hello World"
```json
{
"name": "hello-world",
"version": "1.0.0",
"dependencies": {
"hello": "*",
"world": "*"
},
"web": {
"save": {
"hello-world": "hello-world.js",
"world": {
"to": "world.js",
"url: "/js/world.js"
}
}
}
}
```
## Debug Mode
OneJS also lets you 'require' a splitted file asynchronously.
Pass `--debug` parameter disabling cache and passing ENV variables to the built file. If we assume that we have a module that depends on ENV;
```javascript
if( process.env.VERBOSE ){
console.log( "fabula de narratur" );
}
```js
// hello-world.js
var hello = require('hello');
require.async('world', function(world)){
console.log('dependencies are loaded!');
console.log(world);
// => [object world]
});
```
Above module becomes available to access ENV on debug-mode;
<a name="alias"></a>
### Package Aliases
Registers a new name for specified package. It can be configured via command-line, package.json and NodeJS APIs.
```bash
$ VERBOSE=1 onejs build package.json --debug
$ one build package.json output.js --alias request:superagent,crypto:crypto-browserify
```
## Requiring Global Variables
OneJS doesn't change the way we access global variables. However, we may want to use require statements to access global variables (such as document, jQuery etc..) for purposes like dependency injection or documentation. Following example demonstrates the usage of `--tie` option that lets us require global variables;
```javascript
var $ = require('jquery'),
dom = require('dom'),
pi = require('pi');
$(dom).ready(function(){
console.log( pi == Math.PI ); // true
});
package.json
```json
{
"name": "hello-world",
"web": {
"alias": {
"crypto": "crypto-browserify"
}
}
}
```
```bash
$ onejs build package.json --tie pi=Math.PI,jquery=jQuery,dom=document
NodeJS
```js
one('./package.json')
.alias('crypto', 'crypto-browserify')
.save('foo.js');
```
## Excluding Specific Dependencies
<a name="global-vars"></a>
### Accessing Global Browser Variables
There are some cases we prefer to not have some dependency packages in the build. The `--exclude` option leads OneJS ignore the specified packages;
OneJS doesn't stop you from accessing globals. However, you may want to use `require` for accessing some global variables,
such as jQuery, for some purposes like keeping your source-code self documented.
OneJS may tie some package names to global variables if demanded. And it can be configured via command-line, package.json and NodeJS APIs.
```bash
$ onejs build package.json --exclude underscore,request
$ one build package.json output.js --tie jquery:jQuery,google:goog
```
If the case is to remove a duplication from the build, it would be a good idea to combine `--tie` and `--exclude` together;
package.json
```json
{
"name": "hello-world",
"web": {
"tie": {
"jquery": "jQuery",
"google": "goog"
}
}
}
```
```bash
$ onejs build package.json --exclude underscore --tie underscore=window._
NodeJS
```js
one('./package.json')
.tie('jquery', 'jQuery')
.tie('google', 'goog')
.save('foo.js');
```
## Sandboxing Console Object
<a name="exclude"></a>
### Excluding Packages
OneJS provides an embed, encapsulated console object (disabled by default). Pass `--sandbox-console` if needed, output is available by `projectName.stdout()` and `project.stderr()`.
Excludes specified packages from your bundle.
```bash
$ onejs build package.json foobar.js --sandbox-console
$ one build package.json output.js --excude underscore
```
```javascript
> var foobar = require('./foobar');
> foobar.stdout();
'Trying out the embed console'
'Hello world!'
> foobar.stderr()
'warning! something may be going wrong!'
'error! something went wrong!'
package.json
```json
{
"name": "hello-world",
"web": {
"exclude": ["underscore"]
}
}
```
## NodeJS API
NodeJS
```js
one('./package.json')
.exclude('underscore')
.save('foo.js');
```
You can also use OneJS from inside your own NodeJS code.
<a name="filter"></a>
### Filtering Modules/Files
```javascript
var one = require('one');
OneJS reads .npmignore to ignore anything not wanted to have in the bundle. In addition to .npmignore, you may also
define your own Regex filters to ignore files. This config is only provided for only NodeJS scripts.
var manifest = 'path/to/manifest.json',
target = 'path/to/bundle.js',
options = {
debug: true // see available options section below
};
```js
one('./package.json')
.filter(/^build\.js$/)
.filter(/^bundle\.js$/)
.save('bundle.js');
```
one.build(manifest, options, function(error, bundle){
<a name="api"></a>
## API Reference
OneJS lets you pick any of the following ways to configure your build.
if(error) throw error;
<a name="packagejson"></a>
### package.json
one.save(target, bundle, function(error){
```json
{
"name": "hello-world",
"version": "1.0.0",
"directories": {
"lib": "lib"
},
"web": {
"save": "bundle.js",
"alias": {
"crypto": "crypto-browserify"
},
"tie": {
"jquery": "window.jQuery"
}
}
}
```
if(error) throw error;
<a name="cli"></a>
### Command-Line
console.log('path/to/package.json built and saved to path/to/bundle.js successfully!');
```bash
usage: onejs [action] [manifest] [options]
});
Transforms NodeJS packages into single, stand-alone JavaScript files that can be run at other platforms. See the documentation at http://github.com/azer/onejs for more information.
});
```
actions:
build <manifest> <target> Generate a stand-alone JavaScript file from specified package. Write output to <target> if given any.
server <manifest> <port> <host> Publish generated JavaScript file on web. Uses 127.0.0.1:1338 by default.
#### Available Options
options:
--debug Enable SourceURLs.
* **noprocess:** do not include process module.
* **tie:** Registers given object path as a package. Usage: `tie: [{ 'module': 'pi', 'to': 'Math.PI' }, { 'module': 'json', 'to': 'JSON' }]`
* **exclude:** Exclude specified packages from build. Usage: `exclude: ['underscore', 'request']`
* **ignore:** Modules to ignore. .npmignore will not be read if this option is provided. Usage: `ignore: ['lib/foo.js', 'lib/path/to/a/directory']`
* **sandboxConsole:** Sandboxes console object. Disabled by default.
* **debug:** Enables debug mode. See the Debug Mode section above for information on the affects of this option.
--alias <alias>:<package name> Register an alias name for given package. e.g: request:superagent,crypto:crypto-browserify
--tie <package name>:<global object> Create package links to specified global variables. e.g; --tie dom:window.document,jquery:jQuery
--exclude <package name> Do not contain specified dependencies. e.g: --exclude underscore,request
--plain Builds the package within a minimalistic template for the packages with single module and no dependencies.
#### Applying Filters
--quiet Make console output less verbose.
--verbose Tell what's going on by being verbose.
--version Show version and exit.
--help Show help.
```
Filtering filenames might be a useful option for specific cases such as splitting build to different pieces. Here is an example usage;
<a name="nodejs"></a>
### NodeJS
```javascript
```js
// build.js
var one = require('../../../lib');
var one = require('one');
one('./package.json')
.alias('crypto', 'crypto-browserify')
.tie('pi', 'Math.PI')
.tie('json', 'JSON')
.exclude('underscore')
.filter(/^build\.js$/)
.filter(/^bundle\.js$/)
.save('bundle.js');
```
one.modules.filters.push(function(filename){
return filename.substring(0, 7) != 'lib/foo';
## Examples
// Following examples are out of date. Will be updated soon.
});
* See the example project included in this repository
* MultiplayerChess.com ([Source Code](https://github.com/azer/multiplayerchess.com/tree/master/frontend) - [Output](http://multiplayerchess.com/mpc.js) )
* [ExpressJS built by OneJS](https://gist.github.com/2415048)
* [OneJS built by OneJS](https://gist.github.com/2998719)
```
# Troubleshooting
* The most common issue of a OneJS output is to lack some dependencies. In that case, make sure that the library is located under `node_modules/` properly.
* The most common issue is to lack some dependencies. In that case, make sure that the missing dependency is located under `node_modules/` properly.
* Enabling verbose mode might be helpful: `onejs build package.json --verbose`

@@ -196,0 +331,0 @@ * See the content of `projectName.map` object if it contains the missing dependency

@@ -1,2 +0,1 @@

lib = (function(exports){

@@ -10,21 +9,4 @@

{{#include_process}}
global.process = exports.process = (function(exports){
{{>process}}
return exports;
}({}));
{{/include_process}}
{{#sandbox_console}}
global.console = exports.console = (function(exports){
{{>console}}
return exports;
}({}));
{{/sandbox_console}}
return exports;
}({}));

@@ -1,11 +0,4 @@

{{ treeName }}.module({{ parentId }}, function(/* parent */){
return {
'id': '{{ id }}',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,{{#sandbox_console}} console, {{/sandbox_console}} {{#include_process}}process,{{/include_process}} require, undefined){
{{{content}}}
}
};
});
{{^debug}}'{{ id }}': function(module, exports, global, require, undefined){
{{{content}}}
}, {{/debug}}
{{#debug}}'{{ id }}': Function('module', 'exports', 'global', 'require', 'undefined', {{{contentWithSourceURLs}}}), {{/debug}}

@@ -1,14 +0,11 @@

{{ treeName }}.pkg({{#hasParent}}{{ parentIds }}, {{/hasParent}}function(parents){
{{ treeName }}.pkg({{#hasParent}}{{{ parentIds }}}, {{/hasParent}}function(parents){
return {
'id':{{ id }},
'name':'{{ name }}',
'main':undefined,
'mainModuleId':'{{ main }}',
'modules':[],
'parents':parents
'name' : '{{ name }}',
'main' : undefined,
'mainModuleId' : '{{ main }}',
'modules' : [],
'parents' : parents
};
});
{{{modules}}}
})({ {{{modules}}} });
// Copyright Joyent, Inc. and other Node contributors.
// Minimized fork of NodeJS' path module, based on its an early version.
// Minimized fork of NodeJS' path module, based on an earliest version.

@@ -45,3 +45,1 @@ exports.join = function () {

};

@@ -1,158 +0,42 @@

/*global require:false, Buffer:false, process:false, module:false */
var {{ name }} = (function(unused, undefined){
var {{ name }} = (function(){
var DEBUG = {{#debug}}true{{/debug}}{{^debug}}false{{/debug}},
pkgdefs = {},
pkgmap = {},
var pkgmap = {},
global = {},
lib,
nativeRequire = typeof require != 'undefined' && require,
nativeBuffer = typeof Buffer != 'undefined' && Buffer,
ties, locals;
lib, ties, main, async;
{{#ties}}
ties = {{{ ties }}};
{{/ties}}
function exports(){ return main(); };
{{{library}}}
exports.main = exports;
exports.module = module;
exports.packages = pkgmap;
exports.pkg = pkg;
exports.require = function require(uri){ return pkgmap.main.index.require(uri); };
function findPkg(uri){
return pkgmap[uri];
}
{{#debug}}
exports.debug = true;
{{/debug}}
function findModule(workingModule, uri){
var module,
moduleId = lib.path.join(lib.path.dirname(workingModule.id), uri).replace(/\.js$/, ''),
moduleIndexId = lib.path.join(moduleId, 'index'),
pkg = workingModule.pkg;
{{#ties}}
ties = {{{ ties }}};
{{/ties}}
var i = pkg.modules.length,
id;
{{#aliases}}
aliases = {{{ aliases }}};
{{/aliases}}
while(i-->0){
id = pkg.modules[i].id;
if(id==moduleId || id == moduleIndexId){
module = pkg.modules[i];
break;
}
}
{{#async}}
async = {{{ async }}};
return module;
}
exports.require.async = function(){
return pkgmap.main.index.require.async.apply(null, arguments);
};
{{/async}}
function genRequire(callingModule){
return function require(uri){
var module,
pkg;
return exports;
if(/^\./.test(uri)){
module = findModule(callingModule, uri);
} else if ( ties && ties.hasOwnProperty( uri ) ) {
return ties[ uri ];
} else {
pkg = findPkg(uri);
{{{require}}}
if(!pkg && nativeRequire){
try {
pkg = nativeRequire(uri);
} catch (nativeRequireError) {}
{{{registry}}}
if(pkg) return pkg;
}
if(!pkg){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module = pkg.index;
}
if(!module){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module.parent = callingModule;
return module.call();
};
}
function module(parentId, wrapper){
var parent = pkgdefs[parentId],
mod = wrapper(parent),
cached = false;
mod.exports = {};
mod.require = genRequire(mod);
mod.call = function(){
{{^debug}}
if(cached) {
return mod.exports;
}
cached = true;
{{/debug}}
global.require = mod.require;
mod.wrapper(mod, mod.exports, global, nativeBuffer || global.Buffer, {{#sandbox_console}} global.console,{{/sandbox_console}} {{#include_process}}global.process,{{/include_process}} global.require);
return mod.exports;
};
if(parent.mainModuleId == mod.id){
parent.index = mod;
parent.parents.length === 0 && ( locals.main = mod.call );
}
parent.modules.push(mod);
}
function pkg(/* [ parentId ...], wrapper */){
var wrapper = arguments[ arguments.length - 1 ],
parents = Array.prototype.slice.call(arguments, 0, arguments.length - 1),
ctx = wrapper(parents);
if(pkgdefs.hasOwnProperty(ctx.id)){
throw new Error('Package#'+ctx.id+' "' + ctx.name + '" has duplication of itself.');
}
pkgdefs[ctx.id] = ctx;
pkgmap[ctx.name] = ctx;
arguments.length == 1 && ( pkgmap.main = ctx );
}
function mainRequire(uri){
return pkgmap.main.index.require(uri);
}
function stderr(){
return lib.process.stderr.content;
}
function stdin(){
return lib.process.stdin.content;
}
function stdout(){
return lib.process.stdout.content;
}
return (locals = {
'lib' : lib,
'findPkg' : findPkg,
'findModule' : findModule,
'name' : '{{ name }}',
'module' : module,
'pkg' : pkg,
'packages' : pkgmap,
'stderr' : stderr,
'stdin' : stdin,
'stdout' : stdout,
'require' : mainRequire
{{#debug}}
,'debug' : true
{{/debug}}
});
}(this));

@@ -166,5 +50,4 @@

if( !module.parent ){
{{ name }}.main();
{{ name }}();
}
}
var vegetables = (function(undefined){
var exports = {}, module = { 'exports': exports };
module.exports = ['tomato', 'potato'];
return module.exports;
})();
if(typeof module != 'undefined' && module.exports){
module.exports = vegetables;
};
};

@@ -1,298 +0,204 @@

/*global require:false, Buffer:false, process:false, module:false */
var exampleProject = (function(unused, undefined){
var DEBUG = false,
pkgdefs = {},
pkgmap = {},
var exampleProject = (function(){
var pkgmap = {},
global = {},
lib,
nativeRequire = typeof require != 'undefined' && require,
nativeBuffer = typeof Buffer != 'undefined' && Buffer,
ties, locals;
ties = {"pi": Math.PI, "json": JSON};
lib = (function(exports){
exports.path = (function(exports){
// Copyright Joyent, Inc. and other Node contributors.
// Minimized fork of NodeJS' path module, based on its an early version.
exports.join = function () {
return exports.normalize(Array.prototype.join.call(arguments, "/"));
lib, ties, main, async;
function exports(){ return main(); };
exports.main = exports;
exports.module = module;
exports.packages = pkgmap;
exports.pkg = pkg;
exports.require = function require(uri){ return pkgmap.main.index.require(uri); };
ties = {"pi": Math.PI, "json": JSON};
aliases = {"sibling-alias":"sibling","dependency-alias":"dependency"};
return exports;
function join() {
return normalize(Array.prototype.join.call(arguments, "/"));
};
exports.normalizeArray = function (parts, keepBlanks) {
var directories = [], prev;
for (var i = 0, l = parts.length - 1; i <= l; i++) {
var directory = parts[i];
// if it's blank, but it's not the first thing, and not the last thing, skip it.
if (directory === "" && i !== 0 && i !== l && !keepBlanks) continue;
// if it's a dot, and there was some previous dir already, then skip it.
if (directory === "." && prev !== undefined) continue;
if (
directory === ".." &&
directories.length &&
prev !== ".." &&
prev !== "." &&
prev !== undefined &&
(prev !== "" || keepBlanks)
) {
directories.pop();
prev = directories.slice(-1)[0];
function normalize(path) {
var ret = [], parts = path.split('/'), cur, prev;
var i = 0, l = parts.length-1;
for (; i <= l; i++) {
cur = parts[i];
if (cur === "." && prev !== undefined) continue;
if (cur === ".." && ret.length && prev !== ".." && prev !== "." && prev !== undefined) {
ret.pop();
prev = ret.slice(-1)[0];
} else {
if (prev === ".") directories.pop();
directories.push(directory);
prev = directory;
if (prev === ".") ret.pop();
ret.push(cur);
prev = cur;
}
}
return directories;
return ret.join("/");
};
exports.normalize = function (path, keepBlanks) {
return exports.normalizeArray(path.split("/"), keepBlanks).join("/");
};
exports.dirname = function (path) {
function dirname(path) {
return path && path.substr(0, path.lastIndexOf("/")) || ".";
};
return exports;
}({}));
global.process = exports.process = (function(exports){
/**
* This is module's purpose is to partly emulate NodeJS' process object on web browsers. It's not an alternative
* and/or implementation of the "process" object.
*/
function Buffer(size){
if (!(this instanceof Buffer)) return new Buffer(size);
this.content = '';
};
Buffer.prototype.isBuffer = function isBuffer(){
return true;
};
Buffer.prototype.write = function write(string){
this.content += string;
};
global.Buffer = exports.Buffer = Buffer;
function Stream(writable, readable){
if (!(this instanceof Stream)) return new Stream(writable, readable);
Buffer.call(this);
this.emulation = true;
this.readable = readable;
this.writable = writable;
this.type = 'file';
};
Stream.prototype = Buffer(0,0);
exports.Stream = Stream;
function notImplemented(){
throw new Error('Not Implemented.');
}
exports.binding = (function(){
var table = {
'buffer':{ 'Buffer':Buffer, 'SlowBuffer':Buffer }
};
return function binding(bname){
if(!table.hasOwnProperty(bname)){
throw new Error('No such module.');
function findModule(workingModule, uri){
var moduleId = join(dirname(workingModule.id), uri).replace(/\.js$/, ''),
moduleIndexId = join(moduleId, 'index'),
pkg = workingModule.pkg,
module;
var i = pkg.modules.length,
id;
while(i-->0){
id = pkg.modules[i].id;
if(id==moduleId || id == moduleIndexId){
module = pkg.modules[i];
break;
}
return table[bname];
};
})();
exports.argv = ['onejs'];
exports.env = {};
exports.nextTick = function nextTick(fn){
return setTimeout(fn, 0);
};
exports.stderr = Stream(true, false);
exports.stdin = Stream(false, true);
exports.stdout = Stream(true, false);
exports.version = '1.7.11';
exports.versions = {"one":"1.7.11"};
/**
* void definitions
*/
exports.pid =
exports.uptime = 0;
exports.arch =
exports.execPath =
exports.installPrefix =
exports.platform =
exports.title = '';
exports.chdir =
exports.cwd =
exports.exit =
exports.getgid =
exports.setgid =
exports.getuid =
exports.setuid =
exports.memoryUsage =
exports.on =
exports.umask = notImplemented;
return exports;
}({}));
return exports;
}({}));
function findPkg(uri){
return pkgmap[uri];
}
function findModule(workingModule, uri){
var module,
moduleId = lib.path.join(lib.path.dirname(workingModule.id), uri).replace(/\.js$/, ''),
moduleIndexId = lib.path.join(moduleId, 'index'),
pkg = workingModule.pkg;
var i = pkg.modules.length,
id;
while(i-->0){
id = pkg.modules[i].id;
if(id==moduleId || id == moduleIndexId){
module = pkg.modules[i];
break;
return module;
}
function newRequire(callingModule){
function require(uri){
var module, pkg;
if(/^\./.test(uri)){
module = findModule(callingModule, uri);
} else if ( ties && ties.hasOwnProperty( uri ) ) {
return ties[uri];
} else if ( aliases && aliases.hasOwnProperty( uri ) ) {
return require(aliases[uri]);
} else {
pkg = pkgmap[uri];
if(!pkg && nativeRequire){
try {
pkg = nativeRequire(uri);
} catch (nativeRequireError) {}
if(pkg) return pkg;
}
}
return module;
}
function genRequire(callingModule){
return function require(uri){
var module,
pkg;
if(/^\./.test(uri)){
module = findModule(callingModule, uri);
} else if ( ties && ties.hasOwnProperty( uri ) ) {
return ties[ uri ];
} else {
pkg = findPkg(uri);
if(!pkg && nativeRequire){
try {
pkg = nativeRequire(uri);
} catch (nativeRequireError) {}
if(pkg) return pkg;
}
if(!pkg){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module = pkg.index;
}
if(!module){
if(!pkg){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module.parent = callingModule;
return module.call();
};
}
function module(parentId, wrapper){
var parent = pkgdefs[parentId],
mod = wrapper(parent),
cached = false;
mod.exports = {};
mod.require = genRequire(mod);
mod.call = function(){
if(cached) {
return mod.exports;
}
cached = true;
global.require = mod.require;
mod.wrapper(mod, mod.exports, global, nativeBuffer || global.Buffer, global.process,global.require);
module = pkg.index;
}
if(!module){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module.parent = callingModule;
return module.call();
};
return require;
}
function module(parent, id, wrapper){
var mod = { pkg: parent, id: id, wrapper: wrapper },
cached = false;
mod.exports = {};
mod.require = newRequire(mod);
mod.call = function(){
if(cached) {
return mod.exports;
};
if(parent.mainModuleId == mod.id){
parent.index = mod;
parent.parents.length === 0 && ( locals.main = mod.call );
}
parent.modules.push(mod);
cached = true;
global.require = mod.require;
mod.wrapper(mod, mod.exports, global, global.require);
return mod.exports;
};
if(parent.mainModuleId == mod.id){
parent.index = mod;
parent.parents.length === 0 && ( main = mod.call );
}
function pkg(/* [ parentId ...], wrapper */){
var wrapper = arguments[ arguments.length - 1 ],
parents = Array.prototype.slice.call(arguments, 0, arguments.length - 1),
ctx = wrapper(parents);
if(pkgdefs.hasOwnProperty(ctx.id)){
throw new Error('Package#'+ctx.id+' "' + ctx.name + '" has duplication of itself.');
parent.modules.push(mod);
}
function pkg(/* [ parentId ...], wrapper */){
var wrapper = arguments[ arguments.length - 1 ],
parents = Array.prototype.slice.call(arguments, 0, arguments.length - 1),
ctx = wrapper(parents);
pkgmap[ctx.name] = ctx;
arguments.length == 1 && ( pkgmap.main = ctx );
return function(modules){
var id;
for(id in modules){
module(ctx, id, modules[id]);
}
pkgdefs[ctx.id] = ctx;
pkgmap[ctx.name] = ctx;
arguments.length == 1 && ( pkgmap.main = ctx );
}
function mainRequire(uri){
return pkgmap.main.index.require(uri);
}
function stderr(){
return lib.process.stderr.content;
}
function stdin(){
return lib.process.stdin.content;
}
function stdout(){
return lib.process.stdout.content;
}
return (locals = {
'lib' : lib,
'findPkg' : findPkg,
'findModule' : findModule,
'name' : 'exampleProject',
'module' : module,
'pkg' : pkg,
'packages' : pkgmap,
'stderr' : stderr,
'stdin' : stdin,
'stdout' : stdout,
'require' : mainRequire
});
};
}
}(this));
exampleProject.pkg(1, function(parents){
exampleProject.pkg("example-project", function(parents){
return {
'id':8,
'name':'assert',
'main':undefined,
'mainModuleId':'assert',
'modules':[],
'parents':parents
'name' : 'dependency',
'main' : undefined,
'mainModuleId' : 'f',
'modules' : [],
'parents' : parents
};
});
exampleProject.module(8, function(/* parent */){
return {
'id': 'assert',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
exports.assert = true;
}
};
});
exampleProject.pkg(1, function(parents){
return {
'id':2,
'name':'dependency',
'main':undefined,
'mainModuleId':'f',
'modules':[],
'parents':parents
};
});
exampleProject.module(2, function(/* parent */){
return {
'id': 'f',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
require('subdependency');
})({ 'f': function(module, exports, global, require, undefined){
require('subdependency');
exports.parent = module.parent;
exports.f = true;
}
};
});
exampleProject.module(2, function(/* parent */){
return {
'id': 'g',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
exports.g = true;
}
};
});
},
'g': function(module, exports, global, require, undefined){
exports.g = true;
},
});
exampleProject.pkg(function(parents){
return {
'id':1,
'name':'example-project',
'main':undefined,
'mainModuleId':'a',
'modules':[],
'parents':parents
'name' : 'example-project',
'main' : undefined,
'mainModuleId' : 'a',
'modules' : [],
'parents' : parents
};
});
exampleProject.module(1, function(/* parent */){
return {
'id': 'a',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
console.log('Elle creuse encore, cette vieville amie au regard fatigué.');
var mustacheSyntax = "{{ foobar }}";
})({ 'a': function(module, exports, global, require, undefined){
var mustacheSyntax = "{{ foobar }}";
module.exports = {

@@ -303,179 +209,164 @@ 'a':true,

'global':global,
'process':process,
'Buffer':Buffer,
'console': console,
'mustacheSyntax': mustacheSyntax
};
}
};
});
exampleProject.module(1, function(/* parent */){
},
'b': function(module, exports, global, require, undefined){
exports.b = true;
},
'web': function(module, exports, global, require, undefined){
console.log('this module will be working for only web browsers');
},
});
exampleProject.pkg("dependency", function(parents){
return {
'id': 'b',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
exports.b = true;
}
'name' : 'fruits',
'main' : undefined,
'mainModuleId' : 'index',
'modules' : [],
'parents' : parents
};
});
exampleProject.module(1, function(/* parent */){
})({ 'index': function(module, exports, global, require, undefined){
module.exports = require('./lib/fruits');
},
'lib/fruits': function(module, exports, global, require, undefined){
module.exports = ['apple', 'orange'];
},
});
exampleProject.pkg("dependency", "example-project", function(parents){
return {
'id': 'web',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
console.log('this module will be working for only web browsers');
}
'name' : 'sibling',
'main' : undefined,
'mainModuleId' : 'n',
'modules' : [],
'parents' : parents
};
});
exampleProject.pkg(2, function(parents){
return {
'id':4,
'name':'fruits',
'main':undefined,
'mainModuleId':'index',
'modules':[],
'parents':parents
};
});
exampleProject.module(4, function(/* parent */){
return {
'id': 'index',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
module.exports = require('./lib/fruits');
}
};
});
exampleProject.module(4, function(/* parent */){
return {
'id': 'lib/fruits',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
module.exports = ['apple', 'orange'];
}
};
});
exampleProject.pkg(2, 1, function(parents){
return {
'id':5,
'name':'sibling',
'main':undefined,
'mainModuleId':'n',
'modules':[],
'parents':parents
};
});
exampleProject.module(5, function(/* parent */){
return {
'id': 'n',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
})({ 'n': function(module, exports, global, require, undefined){
exports.n = true;
exports.p = require('./p');
exports.s = require('./s/t');
}
};
});
exampleProject.module(5, function(/* parent */){
return {
'id': 'p/index',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
exports.p = true;
},
'p/index': function(module, exports, global, require, undefined){
exports.p = true;
exports.index = true;
}
};
});
exampleProject.module(5, function(/* parent */){
return {
'id': 'p/r',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
require('../s/t');
},
'p/r': function(module, exports, global, require, undefined){
require('../s/t');
exports.r = true;
}
};
});
exampleProject.module(5, function(/* parent */){
},
's/t': function(module, exports, global, require, undefined){
exports.t = true;
},
});
exampleProject.pkg("dependency", function(parents){
return {
'id': 's/t',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
exports.t = true;
}
'name' : 'subdependency',
'main' : undefined,
'mainModuleId' : 'i',
'modules' : [],
'parents' : parents
};
});
exampleProject.pkg(2, function(parents){
return {
'id':3,
'name':'subdependency',
'main':undefined,
'mainModuleId':'i',
'modules':[],
'parents':parents
};
});
exampleProject.module(3, function(/* parent */){
return {
'id': 'i',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
require('sibling');
})({ 'i': function(module, exports, global, require, undefined){
require('sibling');
exports.i = true;
}
};
});
exampleProject.pkg(2, function(parents){
},
});
exampleProject.pkg("dependency", function(parents){
return {
'id':6,
'name':'vegetables',
'main':undefined,
'mainModuleId':'lib/index',
'modules':[],
'parents':parents
'name' : 'vegetables',
'main' : undefined,
'mainModuleId' : 'lib/index',
'modules' : [],
'parents' : parents
};
});
exampleProject.module(6, function(/* parent */){
})({ 'lib/index': function(module, exports, global, require, undefined){
module.exports = ['tomato', 'potato'];
},
});
exampleProject.pkg("dependency", function(parents){
return {
'id': 'lib/index',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
module.exports = ['tomato', 'potato'];
}
'name' : 'vehicles',
'main' : undefined,
'mainModuleId' : 'index',
'modules' : [],
'parents' : parents
};
});
exampleProject.pkg(2, function(parents){
return {
'id':7,
'name':'vehicles',
'main':undefined,
'mainModuleId':'index',
'modules':[],
'parents':parents
};
});
exampleProject.module(7, function(/* parent */){
return {
'id': 'index',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
module.exports = require('./lib/vehicles');
}
};
});
exampleProject.module(7, function(/* parent */){
return {
'id': 'lib/vehicles',
'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,process,require, undefined){
module.exports = ['car', 'boat', 'truck'];
}
};
});
})({ 'index': function(module, exports, global, require, undefined){
module.exports = require('./lib/vehicles');
},
'lib/vehicles': function(module, exports, global, require, undefined){
module.exports = ['car', 'boat', 'truck'];
},
});
if(typeof module != 'undefined' && module.exports ){
module.exports = exampleProject;
if( !module.parent ){
exampleProject.main();
exampleProject();
}
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc