Skip to content
Permalink
Browse files

Merge pull request #1742 from devongovett/preserve-symlinks

Add support for the Node v6 preserve-symlinks option
  • Loading branch information
goto-bus-stop committed Jan 31, 2018
2 parents b4fcdea + 201708b commit 2b9b31904be01bd67f26db4232c376572bbd366f
@@ -100,6 +100,10 @@ Advanced Options:

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
@@ -14,7 +14,7 @@ module.exports = function (args, opts) {
'boolean': [
'deps', 'pack', 'ig', 'dg', 'im', 'd', 'list', 'builtins',
'commondir', 'bare', 'full-paths', 'bundle-external', 'bf',
'node'
'node', 'preserve-symlinks'
],
string: [ 's', 'r', 'u', 'x', 't', 'i', 'o', 'e', 'c', 'it' ],
alias: {
@@ -107,6 +107,7 @@ module.exports = function (args, opts) {
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,
@@ -502,10 +502,15 @@ Browserify.prototype._createDeps = function (opts) {
}
}
if (err) cb(err, file, pkg)
else if (file) fs.realpath(file, function (err, res) {
cb(err, res, pkg, file);
});
else cb(err, null, pkg)
else if (file) {
if (opts.preserveSymlinks && parent) {
return cb(err, path.resolve(file), pkg, file)
}

fs.realpath(file, function (err, res) {
cb(err, res, pkg, file);
});
} else cb(err, null, pkg)
});
};

@@ -0,0 +1,15 @@
var browserify = require('../');
var vm = require('vm');
var test = require('tap').test;

test('optionally preserves symlinks', function (t) {
t.plan(2);

var b = browserify(__dirname + '/preserve_symlinks/a/index.js', {preserveSymlinks: true});
b.bundle(function (err, buf) {
t.ok(!err);
t.ok(buf);
var src = buf.toString('utf8');
vm.runInNewContext(src, {});
});
});
@@ -0,0 +1 @@
require('b');

Some generated files are not rendered by default. Learn more.

No changes.
@@ -0,0 +1 @@
require('c');

0 comments on commit 2b9b319

Please sign in to comment.
You can’t perform that action at this time.