diff --git a/packager/src/ModuleGraph/Graph.js b/packager/src/ModuleGraph/Graph.js index 27288c317..e8079139a 100644 --- a/packager/src/ModuleGraph/Graph.js +++ b/packager/src/ModuleGraph/Graph.js @@ -46,7 +46,7 @@ type Async$Queue = { }; type LoadQueue = - Async$Queue<{id: string, parent: string}, Callback>>; + Async$Queue<{id: string, parent: ?string}, Callback>>; 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), ); diff --git a/packager/src/ModuleGraph/__tests__/Graph-test.js b/packager/src/ModuleGraph/__tests__/Graph-test.js index 621f489d7..032bd3fda 100644 --- a/packager/src/ModuleGraph/__tests__/Graph-test.js +++ b/packager/src/ModuleGraph/__tests__/Graph-test.js @@ -46,7 +46,7 @@ describe('Graph:', () => { const entryPoint = '/arbitrary/path'; graph([entryPoint], anyPlatform, noOpts, () => { expect(resolve).toBeCalledWith( - entryPoint, '', any(String), any(Object), any(Function)); + entryPoint, null, any(String), any(Object), any(Function)); done(); }); }); @@ -55,9 +55,9 @@ describe('Graph:', () => { const entryPoints = ['Arbitrary', '../entry.js']; graph(entryPoints, anyPlatform, noOpts, () => { expect(resolve).toBeCalledWith( - entryPoints[0], '', any(String), any(Object), any(Function)); + entryPoints[0], null, any(String), any(Object), any(Function)); expect(resolve).toBeCalledWith( - entryPoints[1], '', any(String), any(Object), any(Function)); + entryPoints[1], null, any(String), any(Object), any(Function)); done(); }); @@ -74,7 +74,7 @@ describe('Graph:', () => { const platform = 'any'; graph(anyEntry, platform, noOpts, () => { expect(resolve).toBeCalledWith( - any(String), '', platform, any(Object), any(Function)); + any(String), null, platform, any(Object), any(Function)); done(); }); }); @@ -83,7 +83,7 @@ describe('Graph:', () => { const log = new Console(); graph(anyEntry, anyPlatform, {log}, () => { expect(resolve).toBeCalledWith( - any(String), '', any(String), objectContaining({log}), any(Function)); + any(String), null, any(String), objectContaining({log}), any(Function)); done(); }); }); diff --git a/packager/src/ModuleGraph/node-haste/node-haste.js b/packager/src/ModuleGraph/node-haste/node-haste.js index 3481185b0..daf739a7f 100644 --- a/packager/src/ModuleGraph/node-haste/node-haste.js +++ b/packager/src/ModuleGraph/node-haste/node-haste.js @@ -102,7 +102,7 @@ exports.createResolveFn = function(options: ResolveOptions): ResolveFn { const hasteMapBuilt = hasteMap.build(); const resolutionRequests = {}; const filesByDirNameIndex = new FilesByDirNameIndex(hasteMap.getAllFiles()); - return (id, source: ?string, platform, _, callback) => { + return (id, source, platform, _, callback) => { let resolutionRequest = resolutionRequests[platform]; if (!resolutionRequest) { resolutionRequest = resolutionRequests[platform] = new ResolutionRequest({ diff --git a/packager/src/ModuleGraph/types.flow.js b/packager/src/ModuleGraph/types.flow.js index 2c0c038cf..4e8643b8c 100644 --- a/packager/src/ModuleGraph/types.flow.js +++ b/packager/src/ModuleGraph/types.flow.js @@ -40,7 +40,6 @@ export type GraphFn = ( ) => void; type GraphOptions = {| - cwd?: string, log?: Console, optimize?: boolean, skip?: Set, @@ -90,7 +89,7 @@ export type PackageData = {| export type ResolveFn = ( id: string, - source: string, + source: ?string, platform: string, options?: ResolveOptions, callback: Callback,