From 507fbd7d7ed5648abd2880169d939e919ff01283 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Tue, 21 Nov 2017 06:59:17 -0800 Subject: [PATCH] packager-worker-for-buck: store resolutions at library level Reviewed By: davidaurelio Differential Revision: D6359267 fbshipit-source-id: 795d451c6ff32c07842e9e067778136180a9988e --- .../src/ModuleGraph/types.flow.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/metro-bundler/src/ModuleGraph/types.flow.js b/packages/metro-bundler/src/ModuleGraph/types.flow.js index 4c9c231d..de419be8 100644 --- a/packages/metro-bundler/src/ModuleGraph/types.flow.js +++ b/packages/metro-bundler/src/ModuleGraph/types.flow.js @@ -242,8 +242,35 @@ export type AssetContentsByPath = { +[moduleFilePath: string]: $ReadOnlyArray, }; +export type ResolvedCodeFile = {| + +codeFile: TransformedCodeFile, + /** + * Imagine we have a source file that contains a `require('foo')`. The library + * will resolve the path of the module `foo` and store it in this field along + * all the other dependencies. For example, it could be + * `{'foo': 'bar/foo.js', 'bar': 'node_modules/bar/index.js'}`. + */ + +filePathsByDependencyName: {|+[dependencyName: string]: string|}, +|}; + +/** + * Describe a set of JavaScript files and the associated assets. It could be + * depending on modules from other libraries. To be able to resolve these + * dependencies, these libraries need to be provided by callsites (ex. Buck). + */ export type Library = {| +files: Array, /* cannot be a Map because it's JSONified later on */ +assets: AssetContentsByPath, |}; + +/** + * Just like a `Library`, but it also contains module resolutions. For example + * if there is a `require('foo')` in some JavaScript file, we keep track of the + * path it resolves to, ex. `beep/glo/foo.js`. + */ +export type ResolvedLibrary = {| + +files: $ReadOnlyArray, + /* cannot be a Map because it's JSONified later on */ + +assets: AssetContentsByPath, +|};