Push handling of missing parent module to resolve

Reviewed By: jeanlauliac

Differential Revision: D4863235

fbshipit-source-id: 857814cb25ee661db5e2cbdeac7175d9276044db
This commit is contained in:
David Aurelio
2017-04-11 08:02:23 -07:00
committed by Facebook Github Bot
parent 3bcf4acfc7
commit eabc9cecd6
4 changed files with 11 additions and 13 deletions
+4 -5
View File
@@ -46,7 +46,7 @@ type Async$Queue<T, C> = {
};
type LoadQueue =
Async$Queue<{id: string, parent: string}, Callback<File, Array<string>>>;
Async$Queue<{id: string, parent: ?string}, Callback<File, Array<string>>>;
const createParentModule =
() => ({file: {code: '', type: 'script', path: ''}, dependencies: []});
@@ -57,7 +57,6 @@ const NO_OPTIONS = {};
exports.create = function create(resolve: ResolveFn, load: LoadFn): GraphFn {
function Graph(entryPoints, platform, options, callback = noop) {
const {
cwd = '',
log = (console: any),
optimize = false,
skip,
@@ -74,7 +73,7 @@ exports.create = function create(resolve: ResolveFn, load: LoadFn): GraphFn {
memoize((file, cb) => load(file, {log, optimize}, cb)),
), Number.MAX_SAFE_INTEGER);
const {collect, loadModule} = createGraphHelpers(loadQueue, cwd, skip);
const {collect, loadModule} = createGraphHelpers(loadQueue, skip);
loadQueue.drain = () => {
loadQueue.kill();
@@ -101,7 +100,7 @@ exports.create = function create(resolve: ResolveFn, load: LoadFn): GraphFn {
return Graph;
};
function createGraphHelpers(loadQueue, cwd, skip) {
function createGraphHelpers(loadQueue, skip) {
const modules = new Map([[null, createParentModule()]]);
function collect(
@@ -132,7 +131,7 @@ function createGraphHelpers(loadQueue, cwd, skip) {
function loadModule(id, parent, parentDepIndex) {
loadQueue.push(
{id, parent: parent != null ? parent : cwd},
{id, parent},
(error, file, dependencyIDs) =>
onFileLoaded(error, file, dependencyIDs, id, parent, parentDepIndex),
);