browserify / browserify/resolve
Does the require.resolve `paths` option work just like the `baseDir` option?
- Dominant language
- JavaScript
- Stars
- 796
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
Since Node.js v8.9.0, a new `paths` option was made available to the core Node.js [`require.resolve`](https://nodejs.org/api/modules.html#modules_require_resolve_request_options) function:
> `paths` [``](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Paths to resolve module location from. If present, these paths are used instead of the default resolution paths, with the exception of [`GLOBAL_FOLDERS`](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) like `$HOME/.node_modules`, which are always included. Note that each of these paths is used as a starting point for the module resolution algorithm, meaning that the `node_modules` hierarchy is checked from this location.
As far as I can see, if just given a single element in the `paths` array, this works identical to the `baseDir` option of this module. The new `paths` features does however take into account the `GLOBAL_FOLDERS`, which I'm not sure if this module does?
I ask because I would like to feature detect this and use the internal Node.js function if available, but fall back to this module if not. But I wasn't sure if the behavior was 100% identical 🤔
Contributor guide
Assessment
This issue has not been assessed yet.