Skip to content

Commit 77517c3

Browse files
zkochanljharb
authored andcommitted
[breaking] make preserveSymlinks false by default
followup to browserify#131
1 parent 04cb0bb commit 77517c3

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

lib/node-modules-paths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function nodeModulesPaths(start, opts) {
1111
// resolving against the process' current working directory
1212
var absoluteStart = path.resolve(start);
1313

14-
if (opts && opts.preserveSymlinks === false) {
14+
if (!opts || !opts.preserveSymlinks) {
1515
try {
1616
absoluteStart = fs.realpathSync(absoluteStart);
1717
} catch (err) {

readme.markdown

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ options are:
7373

7474
* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
7575
This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
76-
**Note:** this property is currently `true` by default but it will be changed to
77-
`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.
7876

7977
default `opts` values:
8078

@@ -94,7 +92,7 @@ default `opts` values:
9492
});
9593
},
9694
moduleDirectory: 'node_modules',
97-
preserveSymlinks: true
95+
preserveSymlinks: false
9896
}
9997
```
10098

@@ -127,8 +125,6 @@ options are:
127125

128126
* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
129127
This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
130-
**Note:** this property is currently `true` by default but it will be changed to
131-
`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.
132128

133129
default `opts` values:
134130

@@ -148,7 +144,7 @@ default `opts` values:
148144
return stat.isFile() || stat.isFIFO();
149145
},
150146
moduleDirectory: 'node_modules',
151-
preserveSymlinks: true
147+
preserveSymlinks: false
152148
}
153149
````
154150

test/symlinks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ try {
1717
test('symlink', function (t) {
1818
t.plan(1);
1919

20-
resolve('foo', { basedir: symlinkDir, preserveSymlinks: false }, function (err, res, pkg) {
20+
resolve('foo', { basedir: symlinkDir }, function (err, res, pkg) {
2121
if (err) t.fail(err);
2222
t.equal(res, path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js'));
2323
});
@@ -26,7 +26,7 @@ test('symlink', function (t) {
2626
test('sync symlink when preserveSymlinks = true', function (t) {
2727
t.plan(4);
2828

29-
resolve('foo', { basedir: symlinkDir }, function (err, res, pkg) {
29+
resolve('foo', { basedir: symlinkDir, preserveSymlinks: true }, function (err, res, pkg) {
3030
t.ok(err, 'there is an error');
3131
t.notOk(res, 'no result');
3232

@@ -48,7 +48,7 @@ test('sync symlink', function (t) {
4848

4949
test('sync symlink when preserveSymlinks = true', function (t) {
5050
t.throws(function () {
51-
resolve.sync('foo', { basedir: symlinkDir });
51+
resolve.sync('foo', { basedir: symlinkDir, preserveSymlinks: true });
5252
}, /Cannot find module 'foo'/);
5353
t.end();
5454
});

0 commit comments

Comments
 (0)