metro 0.71.3 → 0.72.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/package.json +23 -21
  2. package/src/Assets.js +3 -2
  3. package/src/Assets.js.flow +3 -2
  4. package/src/Bundler.js +11 -2
  5. package/src/Bundler.js.flow +7 -1
  6. package/src/DeltaBundler/DeltaCalculator.js +83 -21
  7. package/src/DeltaBundler/DeltaCalculator.js.flow +61 -8
  8. package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +3 -2
  9. package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +2 -1
  10. package/src/DeltaBundler/Serializers/helpers/bytecode.js +2 -2
  11. package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +2 -1
  12. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +1 -3
  13. package/src/DeltaBundler/Transformer.js +27 -4
  14. package/src/DeltaBundler/Transformer.js.flow +18 -2
  15. package/src/DeltaBundler/Worker.flow.js +45 -1
  16. package/src/DeltaBundler/Worker.flow.js.flow +42 -1
  17. package/src/DeltaBundler/WorkerFarm.js +3 -2
  18. package/src/DeltaBundler/WorkerFarm.js.flow +3 -1
  19. package/src/DeltaBundler/graphOperations.js +170 -63
  20. package/src/DeltaBundler/graphOperations.js.flow +144 -64
  21. package/src/DeltaBundler/types.flow.js.flow +11 -5
  22. package/src/DeltaBundler.js.flow +1 -1
  23. package/src/HmrServer.js +11 -5
  24. package/src/HmrServer.js.flow +11 -4
  25. package/src/IncrementalBundler.js +22 -4
  26. package/src/IncrementalBundler.js.flow +23 -4
  27. package/src/ModuleGraph/node-haste/HasteFS.js.flow +1 -1
  28. package/src/ModuleGraph/node-haste/Package.js.flow +5 -5
  29. package/src/ModuleGraph/node-haste/node-haste.js +19 -8
  30. package/src/ModuleGraph/node-haste/node-haste.js.flow +43 -16
  31. package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +5 -13
  32. package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +4 -14
  33. package/src/ModuleGraph/output/util.js +3 -4
  34. package/src/ModuleGraph/output/util.js.flow +3 -3
  35. package/src/ModuleGraph/types.flow.js.flow +28 -5
  36. package/src/ModuleGraph/worker/collectDependencies.js +19 -30
  37. package/src/ModuleGraph/worker/collectDependencies.js.flow +23 -41
  38. package/src/Server.js +90 -32
  39. package/src/Server.js.flow +143 -44
  40. package/src/cli-utils.js.flow +1 -1
  41. package/src/commands/build.js +1 -2
  42. package/src/commands/build.js.flow +6 -9
  43. package/src/commands/dependencies.js +1 -1
  44. package/src/commands/serve.js +2 -1
  45. package/src/commands/serve.js.flow +7 -8
  46. package/src/index.flow.js +27 -16
  47. package/src/index.flow.js.flow +24 -15
  48. package/src/integration_tests/basic_bundle/require-context/conflict.js +25 -0
  49. package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +27 -0
  50. package/src/integration_tests/basic_bundle/require-context/empty.js +29 -0
  51. package/src/integration_tests/basic_bundle/require-context/empty.js.flow +26 -0
  52. package/src/integration_tests/basic_bundle/require-context/matching.js +26 -0
  53. package/src/integration_tests/basic_bundle/require-context/matching.js.flow +27 -0
  54. package/src/integration_tests/basic_bundle/require-context/mode-eager.js +22 -0
  55. package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +24 -0
  56. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +22 -0
  57. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +24 -0
  58. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +22 -0
  59. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +24 -0
  60. package/src/integration_tests/basic_bundle/require-context/mode-sync.js +20 -0
  61. package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +22 -0
  62. package/src/integration_tests/basic_bundle/require-context/subdir/a.js +12 -0
  63. package/src/integration_tests/basic_bundle/require-context/subdir/a.js.flow +11 -0
  64. package/src/integration_tests/basic_bundle/require-context/subdir/b.js +18 -0
  65. package/src/integration_tests/basic_bundle/require-context/subdir/b.js.flow +11 -0
  66. package/src/integration_tests/basic_bundle/require-context/subdir/c.js +12 -0
  67. package/src/integration_tests/basic_bundle/require-context/subdir/c.js.flow +11 -0
  68. package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js +12 -0
  69. package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js.flow +11 -0
  70. package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js +12 -0
  71. package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js.flow +11 -0
  72. package/src/integration_tests/basic_bundle/require-context/utils.js +29 -0
  73. package/src/integration_tests/basic_bundle/require-context/utils.js.flow +44 -0
  74. package/src/lib/CountingSet.js +1 -0
  75. package/src/lib/CountingSet.js.flow +1 -0
  76. package/src/lib/RamBundleParser.js +1 -0
  77. package/src/lib/RamBundleParser.js.flow +1 -0
  78. package/src/lib/bundleToBytecode.js +3 -2
  79. package/src/lib/bundleToBytecode.js.flow +2 -2
  80. package/src/lib/contextModule.js +80 -0
  81. package/src/lib/contextModule.js.flow +86 -0
  82. package/src/lib/contextModuleTemplates.js +186 -0
  83. package/src/lib/contextModuleTemplates.js.flow +148 -0
  84. package/src/lib/getGraphId.js +17 -3
  85. package/src/lib/getGraphId.js.flow +12 -9
  86. package/src/lib/getPrependedScripts.js +15 -5
  87. package/src/lib/getPrependedScripts.js.flow +8 -1
  88. package/src/lib/parseCustomResolverOptions.js +26 -0
  89. package/src/lib/parseCustomResolverOptions.js.flow +38 -0
  90. package/src/lib/parseOptionsFromUrl.js +3 -0
  91. package/src/lib/parseOptionsFromUrl.js.flow +9 -18
  92. package/src/lib/splitBundleOptions.js +3 -0
  93. package/src/lib/splitBundleOptions.js.flow +3 -0
  94. package/src/lib/transformHelpers.js +68 -22
  95. package/src/lib/transformHelpers.js.flow +73 -16
  96. package/src/node-haste/DependencyGraph/ModuleResolution.js +19 -2
  97. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +8 -2
  98. package/src/node-haste/DependencyGraph/createHasteMap.js +7 -1
  99. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +7 -1
  100. package/src/node-haste/DependencyGraph.js +39 -9
  101. package/src/node-haste/DependencyGraph.js.flow +63 -12
  102. package/src/node-haste/Module.js +1 -0
  103. package/src/node-haste/Module.js.flow +1 -0
  104. package/src/shared/output/bundle.flow.js +67 -0
  105. package/src/shared/output/bundle.flow.js.flow +89 -0
  106. package/src/shared/output/bundle.js +8 -55
  107. package/src/shared/output/bundle.js.flow +8 -75
  108. package/src/shared/types.flow.js.flow +7 -0
@@ -424,14 +424,20 @@ exports.buildGraph = async function (
424
424
  const bundler = new IncrementalBundler(mergedConfig);
425
425
 
426
426
  try {
427
- return await bundler.buildGraphForEntries(entries, {
428
- ...MetroServer.DEFAULT_GRAPH_OPTIONS,
429
- customTransformOptions,
430
- dev,
431
- minify,
432
- platform,
433
- type,
434
- });
427
+ const {customResolverOptions, ...defaultTransformInputOptions} =
428
+ MetroServer.DEFAULT_GRAPH_OPTIONS;
429
+ return await bundler.buildGraphForEntries(
430
+ entries,
431
+ {
432
+ ...defaultTransformInputOptions,
433
+ customTransformOptions,
434
+ dev,
435
+ minify,
436
+ platform,
437
+ type,
438
+ },
439
+ {customResolverOptions},
440
+ );
435
441
  } finally {
436
442
  bundler.end();
437
443
  }
@@ -448,20 +454,23 @@ exports.attachMetroCli = function (
448
454
  serve: ServeCommandOptions,
449
455
  dependencies: any,
450
456
  ...
451
- } = {},
457
+ }
458
+ // prettier-ignore
459
+ // $FlowFixMe[prop-missing]
460
+ = {},
452
461
  ): Yargs {
462
+ yargs.strict();
463
+
453
464
  if (build) {
454
- const {command, description, builder, handler} = makeBuildCommand();
455
- yargs.command(command, description, builder, handler);
465
+ yargs.command(makeBuildCommand());
456
466
  }
457
467
  if (serve) {
458
- const {command, description, builder, handler} = makeServeCommand();
459
- yargs.command(command, description, builder, handler);
468
+ yargs.command(makeServeCommand());
460
469
  }
461
470
  if (dependencies) {
462
- const {command, description, builder, handler} = makeDependenciesCommand();
463
- yargs.command(command, description, builder, handler);
471
+ yargs.command(makeDependenciesCommand());
464
472
  }
473
+
465
474
  return yargs;
466
475
  };
467
476
 
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _utils = require("./utils");
4
+
5
+ /**
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ *
11
+ * @format
12
+ *
13
+ */
14
+ const normalModule = require("./subdir-conflict");
15
+
16
+ const contextModule = require.context("./subdir-conflict");
17
+
18
+ function main() {
19
+ return {
20
+ normalModule,
21
+ contextModule: (0, _utils.copyContextToObject)(contextModule),
22
+ };
23
+ }
24
+
25
+ module.exports = main();
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import type {RequireWithContext} from './utils';
12
+
13
+ import {copyContextToObject} from './utils';
14
+
15
+ declare var require: RequireWithContext;
16
+
17
+ const normalModule = require('./subdir-conflict');
18
+ const contextModule = require.context('./subdir-conflict');
19
+
20
+ function main() {
21
+ return {
22
+ normalModule,
23
+ contextModule: copyContextToObject(contextModule),
24
+ };
25
+ }
26
+
27
+ module.exports = (main(): mixed);
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @format
10
+ *
11
+ */
12
+ const empty = require.context("./no-such-dir");
13
+
14
+ function main() {
15
+ try {
16
+ empty("./no-such-file.js");
17
+ } catch (e) {
18
+ return {
19
+ error: {
20
+ message: e.message,
21
+ code: e.code,
22
+ },
23
+ };
24
+ }
25
+
26
+ return null;
27
+ }
28
+
29
+ module.exports = main();
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import type {RequireWithContext} from './utils';
12
+
13
+ declare var require: RequireWithContext;
14
+
15
+ const empty = require.context('./no-such-dir');
16
+
17
+ function main() {
18
+ try {
19
+ empty('./no-such-file.js');
20
+ } catch (e) {
21
+ return {error: {message: e.message, code: e.code}};
22
+ }
23
+ return null;
24
+ }
25
+
26
+ module.exports = (main(): mixed);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @format
10
+ *
11
+ */
12
+ const ab = require.context("./subdir", false, /\/(a|b)\.js$/);
13
+
14
+ const abc = require.context("./subdir", false);
15
+
16
+ const abcd = require.context("./subdir", true);
17
+
18
+ function main() {
19
+ return {
20
+ ab: ab.keys(),
21
+ abc: abc.keys(),
22
+ abcd: abcd.keys(),
23
+ };
24
+ }
25
+
26
+ module.exports = main();
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import type {RequireWithContext} from './utils';
12
+
13
+ declare var require: RequireWithContext;
14
+
15
+ const ab = require.context('./subdir', false, /\/(a|b)\.js$/);
16
+ const abc = require.context('./subdir', false);
17
+ const abcd = require.context('./subdir', true);
18
+
19
+ function main() {
20
+ return {
21
+ ab: ab.keys(),
22
+ abc: abc.keys(),
23
+ abcd: abcd.keys(),
24
+ };
25
+ }
26
+
27
+ module.exports = (main(): mixed);
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _utils = require("./utils");
4
+
5
+ /**
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ *
11
+ * @format
12
+ *
13
+ */
14
+ function main() {
15
+ return (0, _utils.awaitProperties)(
16
+ (0, _utils.copyContextToObject)(
17
+ require.context("./subdir", undefined, undefined, "eager")
18
+ )
19
+ );
20
+ }
21
+
22
+ module.exports = main();
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import {copyContextToObject, awaitProperties} from './utils';
12
+ import type {RequireWithContext} from './utils';
13
+
14
+ declare var require: RequireWithContext;
15
+
16
+ function main() {
17
+ return awaitProperties(
18
+ copyContextToObject(
19
+ require.context('./subdir', undefined, undefined, 'eager'),
20
+ ),
21
+ );
22
+ }
23
+
24
+ module.exports = (main(): mixed);
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _utils = require("./utils");
4
+
5
+ /**
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ *
11
+ * @format
12
+ *
13
+ */
14
+ function main() {
15
+ return (0, _utils.awaitProperties)(
16
+ (0, _utils.copyContextToObject)(
17
+ require.context("./subdir", undefined, undefined, "lazy-once")
18
+ )
19
+ );
20
+ }
21
+
22
+ module.exports = main();
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import {copyContextToObject, awaitProperties} from './utils';
12
+ import type {RequireWithContext} from './utils';
13
+
14
+ declare var require: RequireWithContext;
15
+
16
+ function main() {
17
+ return awaitProperties(
18
+ copyContextToObject(
19
+ require.context('./subdir', undefined, undefined, 'lazy-once'),
20
+ ),
21
+ );
22
+ }
23
+
24
+ module.exports = (main(): mixed);
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _utils = require("./utils");
4
+
5
+ /**
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ *
11
+ * @format
12
+ *
13
+ */
14
+ function main() {
15
+ return (0, _utils.awaitProperties)(
16
+ (0, _utils.copyContextToObject)(
17
+ require.context("./subdir", undefined, undefined, "lazy")
18
+ )
19
+ );
20
+ }
21
+
22
+ module.exports = main();
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import {copyContextToObject, awaitProperties} from './utils';
12
+ import type {RequireWithContext} from './utils';
13
+
14
+ declare var require: RequireWithContext;
15
+
16
+ function main() {
17
+ return awaitProperties(
18
+ copyContextToObject(
19
+ require.context('./subdir', undefined, undefined, 'lazy'),
20
+ ),
21
+ );
22
+ }
23
+
24
+ module.exports = (main(): mixed);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _utils = require("./utils");
4
+
5
+ /**
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ *
11
+ * @format
12
+ *
13
+ */
14
+ function main() {
15
+ return (0, _utils.copyContextToObject)(
16
+ require.context("./subdir", undefined, undefined, "sync")
17
+ );
18
+ }
19
+
20
+ module.exports = main();
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict-local
9
+ */
10
+
11
+ import {copyContextToObject} from './utils';
12
+ import type {RequireWithContext} from './utils';
13
+
14
+ declare var require: RequireWithContext;
15
+
16
+ function main() {
17
+ return copyContextToObject(
18
+ require.context('./subdir', undefined, undefined, 'sync'),
19
+ );
20
+ }
21
+
22
+ module.exports = (main(): mixed);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @format
10
+ *
11
+ */
12
+ module.exports = "a";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ module.exports = 'a';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = void 0;
7
+
8
+ /**
9
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ *
14
+ * @format
15
+ *
16
+ */
17
+ var _default = "b";
18
+ exports.default = _default;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ export default 'b';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @format
10
+ *
11
+ */
12
+ module.exports = "c";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ module.exports = 'c';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @format
10
+ *
11
+ */
12
+ module.exports = "d";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ module.exports = 'd';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @format
10
+ *
11
+ */
12
+ module.exports = "contents of subdir-conflict/index.js";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ module.exports = 'contents of subdir-conflict/index.js';
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.copyContextToObject = copyContextToObject;
7
+ exports.awaitProperties = awaitProperties;
8
+
9
+ /**
10
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
11
+ *
12
+ * This source code is licensed under the MIT license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ *
15
+ * @format
16
+ *
17
+ */
18
+ function copyContextToObject(ctx) {
19
+ return Object.fromEntries(ctx.keys().map((key) => [key, ctx(key)]));
20
+ }
21
+
22
+ function awaitProperties(obj) {
23
+ const result = {};
24
+ return Promise.all(
25
+ Object.keys(obj).map((key) => {
26
+ return obj[key].then((value) => (result[key] = value));
27
+ })
28
+ ).then(() => result);
29
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow
9
+ */
10
+
11
+ type ContextModule<T> = {
12
+ (key: string): T,
13
+ keys(): Array<string>,
14
+ };
15
+
16
+ export type RequireWithContext = {
17
+ (id: string): any,
18
+ resolve: (id: string, options?: {paths?: Array<string>, ...}) => string,
19
+ cache: any,
20
+ main: typeof module,
21
+ context<T>(
22
+ name: string,
23
+ recursive?: boolean,
24
+ filter?: RegExp,
25
+ mode?: 'sync' | 'eager' | 'lazy' | 'lazy-once',
26
+ ): ContextModule<T>,
27
+ };
28
+
29
+ export function copyContextToObject<T>(ctx: ContextModule<T>): {
30
+ [key: string]: T,
31
+ } {
32
+ return Object.fromEntries(ctx.keys().map(key => [key, ctx(key)]));
33
+ }
34
+
35
+ export function awaitProperties<T>(
36
+ obj: $ReadOnly<{[key: string]: Promise<T>}>,
37
+ ): Promise<{[key: string]: T}> {
38
+ const result = {};
39
+ return Promise.all(
40
+ Object.keys(obj).map(key => {
41
+ return obj[key].then(value => (result[key] = value));
42
+ }),
43
+ ).then(() => result);
44
+ }
@@ -68,6 +68,7 @@ class CountingSet {
68
68
  }
69
69
  } // Iterate over unique entries
70
70
  // $FlowIssue[unsupported-syntax]
71
+ // $FlowFixMe[missing-local-annot]
71
72
 
72
73
  [Symbol.iterator]() {
73
74
  return this.values();
@@ -81,6 +81,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
81
81
 
82
82
  // Iterate over unique entries
83
83
  // $FlowIssue[unsupported-syntax]
84
+ // $FlowFixMe[missing-local-annot]
84
85
  [Symbol.iterator](): Iterator<T> {
85
86
  return this.values();
86
87
  }
@@ -24,6 +24,7 @@ const HEADER_SIZE = 3;
24
24
  */
25
25
 
26
26
  class RamBundleParser {
27
+ // $FlowFixMe[missing-local-annot]
27
28
  constructor(buffer) {
28
29
  this._buffer = buffer;
29
30
 
@@ -29,6 +29,7 @@ class RamBundleParser {
29
29
  _startupCodeLength: number;
30
30
  _startOffset: number;
31
31
 
32
+ // $FlowFixMe[missing-local-annot]
32
33
  constructor(buffer: Buffer) {
33
34
  this._buffer = buffer;
34
35