Skip to content

Commit

Permalink
Merge branch 'master' into resolve-exposed-folders
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Feb 7, 2019
2 parents 7a16a7d + cfd3af2 commit f6d6728
Show file tree
Hide file tree
Showing 175 changed files with 2,417 additions and 374 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
package-lock.json
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
package-lock=false
23 changes: 19 additions & 4 deletions .travis.yml
@@ -1,8 +1,23 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "10"
- "9"
- "8"
- "6"
- "4"
- "iojs"
- "0.12"
- "0.10"
- "0.8"
- "0.6"
before_install:
- npm install -g npm@~1.4.6
# Old npm certs are untrusted https://github.com/npm/npm/issues/20191
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.8" ]; then export NPM_CONFIG_STRICT_SSL=false; fi'
- 'nvm install-latest-npm'
install:
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
sudo: false
matrix:
fast_finish: true
allow_failures:
- node_js: "0.6"
23 changes: 22 additions & 1 deletion LICENSE
@@ -1,3 +1,24 @@
This software is released under the MIT license:

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---

Some pieces from builtins/ taken from node core under this license:

----
Expand Down Expand Up @@ -29,7 +50,7 @@ buffer_ieee754.js has this license in it:

----

Copyright (c) 2008-2014, Fair Oaks Labs, Inc.
Copyright (c) 2008-2015, Fair Oaks Labs, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
27 changes: 27 additions & 0 deletions appveyor.yml
@@ -0,0 +1,27 @@
environment:
matrix:
- nodejs_version: "10"
- nodejs_version: "9"
- nodejs_version: "8"
- nodejs_version: "6"
- nodejs_version: "4"
- nodejs_version: "0.12"
- nodejs_version: "0.10"

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install modules
- npm install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test

# Don't actually build.
build: off
Binary file added assets/browserify.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion bin/advanced.txt
Expand Up @@ -51,6 +51,24 @@ Advanced Options:
to just "__filename,__dirname". This is handy if you want to run bundles in
node.

--no-browser-field, --no-bf

Turn off package.json browser field resolution. This is also handy if you
need to run a bundle in node.

--transform-key

Instead of the default package.json#browserify#transform field to list
all transforms to apply when running browserify, a custom field, like, e.g.
package.json#browserify#production or package.json#browserify#staging
can be used, by for example running:
* `browserify index.js --transform-key=production > bundle.js`
* `browserify index.js --transform-key=staging > bundle.js`

--node

Alias for --bare and --no-browser-field.

--full-paths

Turn off converting module ids into numerical indexes. This is useful for
Expand All @@ -61,6 +79,10 @@ Advanced Options:
Instead of standard bundle output, print the dependency array generated by
module-deps.

--no-dedupe

Turn off deduping.

--list

Print each file in the dependency graph. Useful for makefiles.
Expand All @@ -70,14 +92,18 @@ Advanced Options:
Consider files with specified EXTENSION as modules, this option can used
multiple times.

--global-transform=MODULE, --g MODULE
--global-transform=MODULE, -g MODULE

Use a transform module on all files after any ordinary transforms have run.

--plugin=MODULE, -p MODULE

Register MODULE as a plugin.

--preserve-symlinks

Preserves symlinks when resolving modules.

Passing arguments to transforms and plugins:

For -t, -g, and -p, you may use subarg syntax to pass options to the
Expand Down
61 changes: 32 additions & 29 deletions bin/args.js
Expand Up @@ -13,12 +13,14 @@ module.exports = function (args, opts) {
var argv = subarg(args, {
'boolean': [
'deps', 'pack', 'ig', 'dg', 'im', 'd', 'list', 'builtins',
'commondir', 'bare', 'full-paths', 'bundle-external'
'commondir', 'bare', 'full-paths', 'bundle-external', 'bf',
'node', 'preserve-symlinks'
],
string: [ 's', 'r', 'u', 'x', 't', 'i', 'o', 'e', 'c', 'it' ],
alias: {
ig: [ 'insert-globals', 'fast' ],
dg: [ 'detect-globals', 'detectGlobals', 'dg' ],
bf: [ 'browser-field', 'browserField' ],
im: 'ignore-missing',
it: 'ignore-transform',
igv: 'insert-global-vars',
Expand All @@ -43,7 +45,10 @@ module.exports = function (args, opts) {
d: false,
builtins: true,
commondir: true,
'bundle-external': true
'bundle-external': true,
bf: true,
dedupe: true,
node: false
}
});

Expand All @@ -57,30 +62,43 @@ module.exports = function (args, opts) {
s.resume();
return rs;
}
return path.resolve(process.cwd(), entry);
return entry;
});

if (argv.bare) {
argv.builtins = false;
argv.commondir = false;
argv.detectGlobals = false;
if (argv.igv === undefined) {
argv.igv = '__filename,__dirname';
}
}

if (argv.igv) {
var insertGlobalVars = {};
var wantedGlobalVars = argv.igv.split(',');
Object.keys(insertGlobals.vars).forEach(function (x) {
if (wantedGlobalVars.indexOf(x) === -1) {
insertGlobalVars[x] = undefined;
}
});
}

var ignoreTransform = argv['ignore-transform'] || argv.it;
var b = browserify(xtend({
node: argv.node,
bare: argv.bare,
noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse],
extensions: [].concat(argv.extension).filter(Boolean),
extensions: [].concat(argv.extension).filter(Boolean).map(function (extension) {
if (extension.charAt(0) != '.') {
return '.' + extension;
} else {
return extension
}
}),
ignoreTransform: [].concat(ignoreTransform).filter(Boolean),
entries: entries,
fullPaths: argv['full-paths'],
builtins: argv.builtins === false ? false : undefined,
commondir: argv.commondir === false ? false : undefined,
bundleExternal: argv['bundle-external'],
basedir: argv.basedir,

browserField: argv.browserField,
transformKey: argv['transform-key'] ? ['browserify', argv['transform-key']] : undefined,
dedupe: argv['dedupe'],
preserveSymlinks: argv['preserve-symlinks'],

detectGlobals: argv.detectGlobals,
insertGlobals: argv['insert-globals'] || argv.ig,
insertGlobalVars: insertGlobalVars,
Expand Down Expand Up @@ -225,24 +243,9 @@ module.exports = function (args, opts) {
return b;
}

var insertGlobalVars;
if (argv.igv) {
insertGlobalVars = argv.igv.split(',').reduce(function (vars, x) {
vars[x] = insertGlobals.vars[x];
return vars;
}, {});
}

return b;
};

function copy (obj) {
return Object.keys(obj).reduce(function (acc, key) {
acc[key] = obj[key];
return acc;
}, {});
}

function splitOnColon (f) {
var pos = f.lastIndexOf(':');
if (pos == -1) {
Expand Down
29 changes: 19 additions & 10 deletions bin/cmd.js
Expand Up @@ -2,6 +2,8 @@
var fs = require('fs');
var JSONStream = require('JSONStream');
var through = require('through2');
var mkdirp = require('mkdirp');
var path = require('path');

var b = require('./args')(process.argv.slice(2));
process.stdout.on('error', process.exit);
Expand All @@ -20,7 +22,7 @@ if (b.argv._[0] === 'help' || b.argv.h || b.argv.help
.on('close', function () { process.exit(1) })
;
}
if (b.argv.v || b.argv.version) {
if (b.argv.version) {
return console.log(require('../package.json').version);
}

Expand Down Expand Up @@ -54,24 +56,25 @@ if (b.argv.list) {

var bundle = b.bundle();
bundle.on('error', errorExit);
bundle.on('end', successExit);

var tmpfile;
var outfile = b.argv.o || b.argv.outfile;
if (outfile) {
bundle.pipe(fs.createWriteStream(outfile));
mkdirp.sync(path.dirname(outfile));

// we'll output to a temp file within same filesystem, then atomically overwrite outfile once successful
tmpfile = outfile + ".tmp-browserify-" + Math.random().toFixed(20).slice(2)
bundle.pipe(fs.createWriteStream(tmpfile));
}
else {
bundle.pipe(process.stdout);
}

function packageFilter (info) {
if (info && typeof info.browserify === 'string' && !info.browser) {
info.browser = info.browserify;
delete info.browserify;
}
return info || {};
}

function errorExit(err) {
if (tmpfile) fs.unlink(tmpfile, function (err) {
if (err) /* no-op, we're already exiting unhappily… */;
});
if (err.stack) {
console.error(err.stack);
}
Expand All @@ -80,3 +83,9 @@ function errorExit(err) {
}
process.exit(1);
}

function successExit() {
if (tmpfile && outfile) fs.rename(tmpfile, outfile, function (err) {
if (err) errorExit(err);
});
}

0 comments on commit f6d6728

Please sign in to comment.