Skip to content

Commit ddd675d

Browse files
hugomrdiastmcw
authored andcommitted
feat: add support for node resolve algo
1 parent a033547 commit ddd675d

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

declarations/comment.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type DocumentationConfig = {
1515
noReferenceLinks?: boolean,
1616
markdownToc?: boolean,
1717
documentExported?: boolean,
18+
resolve?: string,
1819
hljs?: Object
1920
};
2021

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
"doc": "node ./bin/documentation.js build src/index.js -f md --access=public > docs/NODE_API.md",
125125
"self-lint": "node ./bin/documentation.js lint src",
126126
"test": "npm run build && eslint . && flow check && jest",
127-
"test2": "npm run build && flow check && jest",
128127
"test-ci": "npm run build && eslint . && flow check && jest --runInBand"
129128
},
130129
"jest": {

src/commands/shared_options.js

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ module.exports.sharedInputOptions = {
8080
describe: 'The order to sort the documentation',
8181
choices: ['source', 'alpha'],
8282
default: 'source'
83+
},
84+
resolve: {
85+
describe: 'Dependency resolution algorithm.',
86+
choices: ['browser', 'node'],
87+
default: 'browser'
8388
}
8489
};
8590

src/input/dependency.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ function dependencyStream(
7171
})
7272
],
7373
postFilter: moduleFilters.externals(indexes, config),
74-
resolve: (id, opts, cb) => {
75-
const r = require('resolve');
76-
opts.basedir = path.dirname(opts.filename);
77-
r(id, opts, cb);
78-
}
74+
resolve:
75+
config.resolve === 'node' &&
76+
((id, opts, cb) => {
77+
const r = require('resolve');
78+
opts.basedir = path.dirname(opts.filename);
79+
r(id, opts, cb);
80+
})
7981
});
8082
smartGlob(indexes, config.parseExtension).forEach(index => {
8183
md.write(path.resolve(index));

0 commit comments

Comments
 (0)