Socket
Socket
Sign inDemoInstall

browserify

Package Overview
Dependencies
Maintainers
0
Versions
485
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

test/pkg.js

92

index.js

@@ -44,4 +44,4 @@ var fs = require('fs');

+ builtins
+ (req.length ? exports.wrap(req).source : '')
+ (opts.base ? exports.wrapDir(opts.base) : '')
+ (req.length ? exports.wrap(req, opts).source : '')
+ (opts.base ? exports.wrapDir(opts.base, opts) : '')
;

@@ -73,2 +73,3 @@ };

if (!opts) opts = {};
if (!opts.filename) opts.filename = libname;

@@ -82,8 +83,6 @@ if (Array.isArray(libname)) {

var pkg = lib['package.json'];
if (pkg && pkg.dependencies) {
var deps = Object.keys(pkg.dependencies);
var s = exports.wrap(deps, { required : reqs }).source;
reqs.push.apply(reqs, deps);
return lib.source + '\n' + s;
if (lib.dependencies.length) {
var deps = exports.wrap(lib.dependencies, { required : reqs });
reqs.push.apply(reqs, lib.dependencies);
return lib.source + '\n' + deps.source;
}

@@ -95,11 +94,15 @@ else {

return { source : src };
return { source : src, dependencies : [] };
}
else if (opts.required && opts.required.indexOf(libname) >= 0) {
return { source : '' };
return { source : '', dependencies : [] };
}
else if (libname.match(/^[.\/]/)) {
var src = fs.readFileSync(opts.filename || libname, 'utf8');
var body = (opts.filename || libname).match(/\.coffee$/)
? coffee.compile(src) : src
var src = fs.readFileSync(opts.filename, 'utf8');
var body = opts.filename.match(/\.coffee$/)
? coffee.compile(src) : src;
var pkgname = ((opts.name ? opts.name + '/' : '') + libname)
.replace(/\/\.\//g, '/')
.replace(/\/\.$/, '')
;

@@ -111,5 +114,6 @@

.replace(/\$filename/g, function () {
return JSON.stringify(libname)
return JSON.stringify(pkgname);
})
,
dependencies : [],
};

@@ -119,2 +123,7 @@ }

var body = fs.readFileSync(require.resolve(libname), 'utf8');
var pkgname = ((opts.name ? opts.name + '/' : '') + libname)
.replace(/\/\.\//g, '/')
.replace(/\/\.$/, '')
;
var src = wrapperBody

@@ -125,6 +134,6 @@ .replace('$body', function () {

.replace(/\$filename/g, function () {
return JSON.stringify(libname)
return JSON.stringify(pkgname)
})
;
return { source : src };
return { source : src, dependencies : [] };
}

@@ -137,2 +146,3 @@ else {

'package.json' : pkg,
dependencies : Object.keys(pkg.dependencies || {}),
source : Object.keys(mods)

@@ -159,8 +169,32 @@ .filter(function (name) {

var find = require('findit');
exports.wrapDir = function (base) {
exports.wrapDir = function (base, opts) {
if (!opts) opts = {};
if (Array.isArray(base)) {
return base.map(exports.wrapDir).join('\n');
return base.map(function (file) {
exports.wrapDir(file, opts)
}).join('\n');
}
else {
return find.sync(base)
var pkg = path.existsSync(base + '/package.json')
? JSON.parse(fs.readFileSync(base + '/package.json', 'utf8'))
: {}
;
function params (key) {
return opts[key]
|| (pkg.browserify && pkg.browserify[key])
|| pkg[key]
}
var main = params('main');
if (main && typeof pkg.browserify === 'object'
&& !pkg.browserify.base) {
var files = [ base + '/' + main ];
}
else {
var files = find.sync(base);
}
return files
.filter(function (file) {

@@ -171,7 +205,13 @@ return file.match(/\.(?:js|coffee)$/)

.map(function (file) {
return exports.wrap(
'.' + file.slice(base.length)
.replace(/\.(?:js|coffee)$/,'')
, { filename : file }
).source;
var libname = unext(file.slice(base.length + 1));
if (!libname.match(/^\.\//)) libname = './' + libname;
var pkgname = main && (
unext(main) === file || unext(main) === libname
) ? '.' : libname;
return exports.wrap(pkgname, {
filename : file,
name : params('name'),
}).source;
})

@@ -182,1 +222,5 @@ .join('\n')

};
function unext (s) {
return s.replace(/\.(?:js|coffee)$/,'');
}
{
"name" : "browserify",
"version" : "0.1.5",
"version" : "0.2.0",
"description" : "Browser-side require() for js directories and npm modules",

@@ -21,3 +21,3 @@ "main" : "./index.js",

"dependencies" : {
"findit" : ">=0.0.1",
"findit" : ">=0.0.3",
"source" : ">=0.0.3",

@@ -24,0 +24,0 @@ "es5-shim" : ">=1.0.0",

@@ -6,5 +6,8 @@ Browserify

Browserify bundles everything ahead-of-time at the mount point you specify.
None of this ajaxy module loading business.
Browserify bundles all of your javascript when your server fires up at the mount
point you specify.
Browserify does not use xhr, ajax loading, script tag injection, or any of that
noise.
More features:

@@ -20,2 +23,5 @@

* bundle browser source components of modules specially with the "browserify"
package.json field
examples

@@ -135,2 +141,4 @@ ========

browserify.bundle(base)
-----------------------
browserify.bundle(opts)

@@ -142,9 +150,30 @@ -----------------------

* base : recursively bundle all `.js` and `.coffee` files in this directory or
Array of directories
Array of directories. If there is a package.json at `base`, it will be read
according to the procedure below.
* name : preface the files in `base` with this name
* main : map `require(name)` for the `name` field to this file
* shim : whether to include [es5-shim](https://github.com/kriskowal/es5-shim)
for legacy javascript engines; true if unspecified
* require : bundle all of these module names and their dependencies
* require : bundle all of these module names and their dependencies.
If the name has a slash in it, only that file will be included, otherwise
all .js and .coffee files which are not in the test directory and are not
binaries will be bundled into the final output.
package.json
============
During bundling the package.json of a module or base directory will be read for
its `name` and `main` fields, which will be used unless those fields are defined
in `opts`.
If the package.json has a "browserify" field, its contents will take precedence
over the standard package.json contents. This special field is meant for
packages that have a special browser-side component like dnode and socket.io.
If a main is specified in a "browserify" hash and no "base" is given, only that
"main" file will be bundled.
compatability

@@ -151,0 +180,0 @@ =============

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