You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It implements a _strict_ version of Node.js modules resolution logic, differences are as follows:
12
12
13
-
*[Loading from global folders](https://nodejs.org/api/all.html#all_loading_from_the_global_folders) is not supported
14
-
* Only Unix path separators (`/`) are supported in require's _path_ arguments (_Background: even though Node.js internally seems to follow Windows path separator in Windows environment, it won't work in \*nix environments, and even in Window env it's [not reliable](https://github.com/nodejs/node/issues/6049) so by all means should be avoided_)
15
-
* There's no awareness of node.js [core modules](https://nodejs.org/api/all.html#all_core_modules)
13
+
-[Loading from global folders](https://nodejs.org/api/all.html#all_loading_from_the_global_folders) is not supported
14
+
- Only Unix path separators (`/`) are supported in require's _path_ arguments (_Background: even though Node.js internally seems to follow Windows path separator in Windows environment, it won't work in \*nix environments, and even in Window env it's [not reliable](https://github.com/nodejs/node/issues/6049) so by all means should be avoided_)
15
+
- There's no awareness of node.js [core modules](https://nodejs.org/api/all.html#all_core_modules)
16
16
e.g. `resolve(dir, 'fs')` will naturally result with _null_
For provided configuration, returns a CJS modules resolver:
27
27
28
-
***extensions** - List of supported file extensions in order of singificance, e.g. for Node.js it would be `['.js', '.json', '.node']`
29
-
***confirmFile** - a `confirmFile(filepath)` function. Confirms whether there's a module at provided (not normalized, absolute) file path. Returns promise-like object which resolves with either normalized full path of a module or null (if there's no module for given path).
28
+
-**extensions** - List of supported file extensions in order of singificance, e.g. for Node.js it would be `['.js', '.json', '.node']`
29
+
-**confirmFile** - a `confirmFile(filepath)` function. Confirms whether there's a module at provided (not normalized, absolute) file path. Returns promise-like object which resolves with either normalized full path of a module or null (if there's no module for given path).
30
30
Although result is expected to be a promise-like object, resolution can be synchronous.
31
-
***resolvePackageMain** - a `resolvePackageMain(dirpath)` function. Returns value of _package.json_'s `main` property for given path. Returns promise-like object which resolves with either resolved value, or null, when either `package.json` file was not found, or it didn't have _main_ property.
31
+
-**resolvePackageMain** - a `resolvePackageMain(dirpath)` function. Returns value of _package.json_'s `main` property for given path. Returns promise-like object which resolves with either resolved value, or null, when either `package.json` file was not found, or it didn't have _main_ property.
32
32
Same as with `confirmFile` resolution can be synchronous.
33
33
34
34
#### resolve(dir, path)
@@ -40,7 +40,7 @@ Returns promise. If no matching module was found, promise resolves with `null` o
40
40
full module path becomes a resolved value.
41
41
42
42
```javascript
43
-
var resolve =require("cjs-module/resolve");
43
+
var resolve =require("ncjsm/resolve");
44
44
45
45
// Asynchronously resolve path for 'foo' module against current path
Resolve all module dependencies. Returns promise that resolves with an array of paths, that includes path to input module and paths to all its dependencies (it includes deep dependencies, so also dependencies of the dependencies)
119
119
120
120
```javascript
121
-
var getDependencies =require("cjs-module/get-dependencies");
121
+
var getDependencies =require("ncjsm/get-dependencies");
122
122
123
123
getDependencies(modulePath).done(function(deps) {
124
124
console.log(deps); // e.g. [pathToModulePath, pathToDep1, pathToDep2, ...pathToDepn]
0 commit comments