Skip to content

Commit 1f8f13f

Browse files
author
Thomas Heymann
committed
Added: preserveSymlinks option to control dependency resolution
1 parent 5db28c3 commit 1f8f13f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ You can use [resolve](https://github.com/substack/node-resolve) for this.
148148
#### `load`
149149

150150
Type: `Function`
151-
Default: null
151+
Default: `null`
152152

153153
You can overwrite the default loading way by setting this option.
154154
This function gets `(filename, importOptions)` arguments and returns content or
@@ -177,6 +177,14 @@ This option is only for adding additional directories to default resolver. If
177177
you provide your own resolver via the `resolve` configuration option above, then
178178
this value will be ignored.
179179

180+
#### `preserveSymlinks`
181+
182+
Type: `Boolean`
183+
Default: `true`
184+
185+
If true, does not resolve symlinks to real paths before resolving dependencies. This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
186+
_Note: Set to false to use Node's default resolution algorithm._
187+
180188
#### Example with some options
181189

182190
```js

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function AtImport(options) {
2222
load: loadContent,
2323
plugins: [],
2424
addModulesDirectories: [],
25+
preserveSymlinks: true,
2526
},
2627
options
2728
)

lib/resolve-id.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function resolveModule(id, opts) {
1313

1414
module.exports = function(id, base, options) {
1515
const paths = options.path
16+
const preserveSymlinks = options.preserveSymlinks
1617

1718
const resolveOpts = {
1819
basedir: base,
@@ -24,6 +25,7 @@ module.exports = function(id, base, options) {
2425
else if (!pkg.main || !/\.css$/.test(pkg.main)) pkg.main = "index.css"
2526
return pkg
2627
},
28+
preserveSymlinks: preserveSymlinks,
2729
}
2830

2931
return resolveModule(`./${id}`, resolveOpts)

0 commit comments

Comments
 (0)