metro 0.75.0 → 0.76.0

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 (63) hide show
  1. package/package.json +23 -24
  2. package/src/Assets.js +2 -2
  3. package/src/Assets.js.flow +1 -1
  4. package/src/DeltaBundler/DeltaCalculator.js +18 -11
  5. package/src/DeltaBundler/DeltaCalculator.js.flow +15 -11
  6. package/src/DeltaBundler/Graph.js +11 -28
  7. package/src/DeltaBundler/Graph.js.flow +7 -0
  8. package/src/DeltaBundler/Serializers/helpers/js.js +2 -7
  9. package/src/DeltaBundler/types.flow.js.flow +2 -7
  10. package/src/HmrServer.js +9 -32
  11. package/src/IncrementalBundler.js +9 -9
  12. package/src/IncrementalBundler.js.flow +4 -0
  13. package/src/ModuleGraph/worker/collectDependencies.js +53 -89
  14. package/src/ModuleGraph/worker/collectDependencies.js.flow +113 -141
  15. package/src/Server/symbolicate.js +1 -5
  16. package/src/Server.js +15 -53
  17. package/src/Server.js.flow +5 -0
  18. package/src/commands/dependencies.js +1 -5
  19. package/src/index.flow.js +1 -2
  20. package/src/integration_tests/basic_bundle/TestBigInt.js +0 -3
  21. package/src/integration_tests/basic_bundle/TestBigInt.js.flow +0 -3
  22. package/src/integration_tests/basic_bundle/require-context/mode-sync.js +1 -0
  23. package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +1 -0
  24. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js +28 -0
  25. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +33 -0
  26. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js +20 -0
  27. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +23 -0
  28. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js +18 -0
  29. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +21 -0
  30. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js +28 -0
  31. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +33 -0
  32. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js +19 -0
  33. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js.flow +18 -0
  34. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js +13 -0
  35. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js.flow +11 -0
  36. package/src/integration_tests/basic_bundle/require-resolveWeak/utils.js +1 -0
  37. package/src/integration_tests/basic_bundle/require-resolveWeak/utils.js.flow +14 -0
  38. package/src/lib/CountingSet.js +1 -5
  39. package/src/lib/RamBundleParser.js +0 -1
  40. package/src/lib/RamBundleParser.js.flow +0 -1
  41. package/src/lib/TerminalReporter.js +9 -17
  42. package/src/lib/TerminalReporter.js.flow +7 -0
  43. package/src/lib/contextModuleTemplates.js +1 -1
  44. package/src/lib/contextModuleTemplates.js.flow +1 -1
  45. package/src/lib/formatBundlingError.js +0 -3
  46. package/src/lib/formatBundlingError.js.flow +0 -3
  47. package/src/lib/getAppendScripts.js +0 -3
  48. package/src/lib/getAppendScripts.js.flow +0 -3
  49. package/src/lib/getGraphId.js +2 -11
  50. package/src/lib/getPrependedScripts.js +2 -1
  51. package/src/lib/getPrependedScripts.js.flow +2 -1
  52. package/src/lib/reporting.js.flow +4 -0
  53. package/src/lib/transformHelpers.js +16 -22
  54. package/src/lib/transformHelpers.js.flow +7 -8
  55. package/src/node-haste/DependencyGraph/ModuleResolution.js +13 -11
  56. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +17 -5
  57. package/src/node-haste/DependencyGraph/createHasteMap.js +13 -38
  58. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +2 -1
  59. package/src/node-haste/DependencyGraph.js +28 -22
  60. package/src/node-haste/DependencyGraph.js.flow +25 -9
  61. package/src/node-haste/Module.js +5 -3
  62. package/src/node-haste/Module.js.flow +2 -3
  63. package/src/node-haste/ModuleCache.js +1 -5
package/src/Server.js CHANGED
@@ -96,7 +96,6 @@ class Server {
96
96
  return this._createModuleId;
97
97
  }
98
98
  async build(options) {
99
- var _this$_config$server$;
100
99
  const {
101
100
  entryFile,
102
101
  graphOptions,
@@ -140,10 +139,7 @@ class Server {
140
139
  sourceUrl: serializerOptions.sourceUrl,
141
140
  inlineSourceMap: serializerOptions.inlineSourceMap,
142
141
  serverRoot:
143
- (_this$_config$server$ = this._config.server.unstable_serverRoot) !==
144
- null && _this$_config$server$ !== void 0
145
- ? _this$_config$server$
146
- : this._config.projectRoot,
142
+ this._config.server.unstable_serverRoot ?? this._config.projectRoot,
147
143
  };
148
144
  let bundleCode = null;
149
145
  let bundleMap = null;
@@ -180,7 +176,6 @@ class Server {
180
176
  };
181
177
  }
182
178
  async getRamBundleInfo(options) {
183
- var _this$_config$server$2;
184
179
  const {
185
180
  entryFile,
186
181
  graphOptions,
@@ -227,10 +222,7 @@ class Server {
227
222
  sourceUrl: serializerOptions.sourceUrl,
228
223
  inlineSourceMap: serializerOptions.inlineSourceMap,
229
224
  serverRoot:
230
- (_this$_config$server$2 = this._config.server.unstable_serverRoot) !==
231
- null && _this$_config$server$2 !== void 0
232
- ? _this$_config$server$2
233
- : this._config.projectRoot,
225
+ this._config.server.unstable_serverRoot ?? this._config.projectRoot,
234
226
  });
235
227
  }
236
228
  async getAssets(options) {
@@ -386,24 +378,12 @@ class Server {
386
378
  bundlePerfLogger: noopLogger,
387
379
  });
388
380
  } else {
389
- var _this$_config$unstabl, _this$_config$unstabl2, _this$_config;
390
381
  await this._processBundleRequest(req, res, options, {
391
382
  buildNumber,
392
383
  bundlePerfLogger:
393
- (_this$_config$unstabl =
394
- (_this$_config$unstabl2 = (_this$_config = this._config)
395
- .unstable_perfLoggerFactory) === null ||
396
- _this$_config$unstabl2 === void 0
397
- ? void 0
398
- : _this$_config$unstabl2.call(
399
- _this$_config,
400
- "BUNDLING_REQUEST",
401
- {
402
- key: buildNumber,
403
- }
404
- )) !== null && _this$_config$unstabl !== void 0
405
- ? _this$_config$unstabl
406
- : noopLogger,
384
+ this._config.unstable_perfLoggerFactory?.("BUNDLING_REQUEST", {
385
+ key: buildNumber,
386
+ }) ?? noopLogger,
407
387
  });
408
388
  }
409
389
  if (this._serverOptions && this._serverOptions.onBundleBuilt) {
@@ -628,7 +608,6 @@ class Server {
628
608
  }
629
609
  _processBundleRequest = this._createRequestProcessor({
630
610
  createStartEntry(context) {
631
- var _context$req$headers$;
632
611
  return {
633
612
  action_name: "Requesting bundle",
634
613
  bundle_url: context.req.url,
@@ -637,11 +616,7 @@ class Server {
637
616
  build_id: getBuildID(context.buildNumber),
638
617
  bundle_options: context.bundleOptions,
639
618
  bundle_hash: context.graphId,
640
- user_agent:
641
- (_context$req$headers$ = context.req.headers["user-agent"]) !==
642
- null && _context$req$headers$ !== void 0
643
- ? _context$req$headers$
644
- : "unknown",
619
+ user_agent: context.req.headers["user-agent"] ?? "unknown",
645
620
  };
646
621
  },
647
622
  createEndEntry(context) {
@@ -659,7 +634,6 @@ class Server {
659
634
  transformOptions,
660
635
  bundlePerfLogger,
661
636
  }) => {
662
- var _this$_config$server$3;
663
637
  bundlePerfLogger.start();
664
638
  bundlePerfLogger.annotate({
665
639
  string: {
@@ -668,6 +642,11 @@ class Server {
668
642
  });
669
643
  const revPromise = this._bundler.getRevisionByGraphId(graphId);
670
644
  bundlePerfLogger.point("resolvingAndTransformingDependencies_start");
645
+ bundlePerfLogger.annotate({
646
+ bool: {
647
+ initial_build: revPromise == null,
648
+ },
649
+ });
671
650
  const { delta, revision } = await (revPromise != null
672
651
  ? this._bundler.updateGraph(await revPromise, false)
673
652
  : this._bundler.initializeGraph(
@@ -716,11 +695,7 @@ class Server {
716
695
  sourceUrl: serializerOptions.sourceUrl,
717
696
  inlineSourceMap: serializerOptions.inlineSourceMap,
718
697
  serverRoot:
719
- (_this$_config$server$3 =
720
- this._config.server.unstable_serverRoot) !== null &&
721
- _this$_config$server$3 !== void 0
722
- ? _this$_config$server$3
723
- : this._config.projectRoot,
698
+ this._config.server.unstable_serverRoot ?? this._config.projectRoot,
724
699
  }
725
700
  );
726
701
  bundlePerfLogger.point("serializingBundle_end");
@@ -793,7 +768,6 @@ class Server {
793
768
  serializerOptions,
794
769
  transformOptions,
795
770
  }) => {
796
- var _this$_config$server$4;
797
771
  const revPromise = this._bundler.getRevisionByGraphId(graphId);
798
772
  const { delta, revision } = await (revPromise != null
799
773
  ? this._bundler.updateGraph(await revPromise, false)
@@ -833,11 +807,7 @@ class Server {
833
807
  sourceUrl: serializerOptions.sourceUrl,
834
808
  inlineSourceMap: serializerOptions.inlineSourceMap,
835
809
  serverRoot:
836
- (_this$_config$server$4 =
837
- this._config.server.unstable_serverRoot) !== null &&
838
- _this$_config$server$4 !== void 0
839
- ? _this$_config$server$4
840
- : this._config.projectRoot,
810
+ this._config.server.unstable_serverRoot ?? this._config.projectRoot,
841
811
  })
842
812
  );
843
813
  return {
@@ -998,10 +968,7 @@ class Server {
998
968
  ) {
999
969
  continue;
1000
970
  }
1001
- const fileAbsolute = path.resolve(
1002
- this._config.projectRoot,
1003
- file !== null && file !== void 0 ? file : ""
1004
- );
971
+ const fileAbsolute = path.resolve(this._config.projectRoot, file ?? "");
1005
972
  try {
1006
973
  return {
1007
974
  content: codeFrameColumns(
@@ -1194,12 +1161,7 @@ class Server {
1194
1161
  sourceUrl: null,
1195
1162
  };
1196
1163
  _getServerRootDir() {
1197
- var _this$_config$server$5;
1198
- return (_this$_config$server$5 =
1199
- this._config.server.unstable_serverRoot) !== null &&
1200
- _this$_config$server$5 !== void 0
1201
- ? _this$_config$server$5
1202
- : this._config.projectRoot;
1164
+ return this._config.server.unstable_serverRoot ?? this._config.projectRoot;
1203
1165
  }
1204
1166
  _getEntryPointAbsolutePath(entryFile) {
1205
1167
  return path.resolve(this._getServerRootDir(), entryFile);
@@ -832,6 +832,11 @@ class Server {
832
832
  const revPromise = this._bundler.getRevisionByGraphId(graphId);
833
833
 
834
834
  bundlePerfLogger.point('resolvingAndTransformingDependencies_start');
835
+ bundlePerfLogger.annotate({
836
+ bool: {
837
+ initial_build: revPromise == null,
838
+ },
839
+ });
835
840
  const {delta, revision} = await (revPromise != null
836
841
  ? this._bundler.updateGraph(await revPromise, false)
837
842
  : this._bundler.initializeGraph(
@@ -17,7 +17,6 @@ const fs = require("fs");
17
17
  const { loadConfig } = require("metro-config");
18
18
  const path = require("path");
19
19
  async function dependencies(args, config) {
20
- var _config$server$unstab;
21
20
  const rootModuleAbsolutePath = args.entryFile;
22
21
  if (!fs.existsSync(rootModuleAbsolutePath)) {
23
22
  return Promise.reject(
@@ -26,10 +25,7 @@ async function dependencies(args, config) {
26
25
  }
27
26
  config.cacheStores = [];
28
27
  const relativePath = path.relative(
29
- (_config$server$unstab = config.server.unstable_serverRoot) !== null &&
30
- _config$server$unstab !== void 0
31
- ? _config$server$unstab
32
- : config.projectRoot,
28
+ config.server.unstable_serverRoot ?? config.projectRoot,
33
29
  rootModuleAbsolutePath
34
30
  );
35
31
  const options = {
package/src/index.flow.js CHANGED
@@ -45,8 +45,7 @@ async function runMetro(config, options) {
45
45
  port,
46
46
  type: "initialize_started",
47
47
  });
48
- const { waitForBundler = false, ...serverOptions } =
49
- options !== null && options !== void 0 ? options : {};
48
+ const { waitForBundler = false, ...serverOptions } = options ?? {};
50
49
  const server = new MetroServer(mergedConfig, serverOptions);
51
50
  const readyPromise = server
52
51
  .ready()
@@ -10,11 +10,8 @@
10
10
 
11
11
  "use strict";
12
12
 
13
- // $FlowIssue[bigint-unsupported]
14
13
  // $FlowFixMe[signature-verification-failure]
15
14
  var a = 2n;
16
- // $FlowIssue[bigint-unsupported]
17
15
  // $FlowFixMe[signature-verification-failure]
18
16
  var b = 3n;
19
- // $FlowFixMe[unsafe-addition]
20
17
  module.exports = a ** b;
@@ -10,11 +10,8 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- // $FlowIssue[bigint-unsupported]
14
13
  // $FlowFixMe[signature-verification-failure]
15
14
  var a = 2n;
16
- // $FlowIssue[bigint-unsupported]
17
15
  // $FlowFixMe[signature-verification-failure]
18
16
  var b = 3n;
19
- // $FlowFixMe[unsafe-addition]
20
17
  module.exports = a ** b;
@@ -13,6 +13,7 @@ var _utils = require("./utils");
13
13
 
14
14
  function main() {
15
15
  return (0, _utils.copyContextToObject)(
16
+ // $FlowFixMe[underconstrained-implicit-instantiation]
16
17
  require.context("./subdir", undefined, undefined, "sync")
17
18
  );
18
19
  }
@@ -15,6 +15,7 @@ declare var require: RequireWithContext;
15
15
 
16
16
  function main(): mixed {
17
17
  return copyContextToObject(
18
+ // $FlowFixMe[underconstrained-implicit-instantiation]
18
19
  require.context('./subdir', undefined, undefined, 'sync'),
19
20
  );
20
21
  }
@@ -0,0 +1,28 @@
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
+
13
+ async function main() {
14
+ const moduleId = require.resolveWeak("./subdir/counter-module");
15
+
16
+ // Require the module statically via its path, spelled slightly differently
17
+ (await import("./subdir/counter-module.js")).increment();
18
+ const dynamicRequire = require;
19
+
20
+ // Require the module dynamically via its ID
21
+ const timesIncremented = dynamicRequire(moduleId).increment();
22
+ return {
23
+ moduleId,
24
+ // Should be 2, proving there's just one module instance
25
+ timesIncremented,
26
+ };
27
+ }
28
+ module.exports = main();
@@ -0,0 +1,33 @@
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 {RequireWithResolveWeak} from './utils';
12
+
13
+ declare var require: RequireWithResolveWeak;
14
+
15
+ async function main() {
16
+ const moduleId = require.resolveWeak('./subdir/counter-module');
17
+
18
+ // Require the module statically via its path, spelled slightly differently
19
+ (await import('./subdir/counter-module.js')).increment();
20
+
21
+ const dynamicRequire = require;
22
+
23
+ // Require the module dynamically via its ID
24
+ const timesIncremented = dynamicRequire(moduleId).increment();
25
+
26
+ return {
27
+ moduleId,
28
+ // Should be 2, proving there's just one module instance
29
+ timesIncremented,
30
+ };
31
+ }
32
+
33
+ module.exports = (main(): mixed);
@@ -0,0 +1,20 @@
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
+
13
+ async function main() {
14
+ return {
15
+ counterModuleId1: require.resolveWeak("./subdir/counter-module"),
16
+ counterModuleId2: require.resolveWeak("./subdir/counter-module.js"),
17
+ throwingModuleId: require.resolveWeak("./subdir/throwing-module.js"),
18
+ };
19
+ }
20
+ module.exports = main();
@@ -0,0 +1,23 @@
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 {RequireWithResolveWeak} from './utils';
12
+
13
+ declare var require: RequireWithResolveWeak;
14
+
15
+ async function main() {
16
+ return {
17
+ counterModuleId1: require.resolveWeak('./subdir/counter-module'),
18
+ counterModuleId2: require.resolveWeak('./subdir/counter-module.js'),
19
+ throwingModuleId: require.resolveWeak('./subdir/throwing-module.js'),
20
+ };
21
+ }
22
+
23
+ module.exports = (main(): mixed);
@@ -0,0 +1,18 @@
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
+
13
+ function main() {
14
+ return {
15
+ moduleId: require.resolveWeak("./subdir/throwing-module"),
16
+ };
17
+ }
18
+ module.exports = main();
@@ -0,0 +1,21 @@
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 {RequireWithResolveWeak} from './utils';
12
+
13
+ declare var require: RequireWithResolveWeak;
14
+
15
+ function main() {
16
+ return {
17
+ moduleId: require.resolveWeak('./subdir/throwing-module'),
18
+ };
19
+ }
20
+
21
+ module.exports = (main(): mixed);
@@ -0,0 +1,28 @@
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
+
13
+ function main() {
14
+ const moduleId = require.resolveWeak("./subdir/counter-module");
15
+ const dynamicRequire = require;
16
+
17
+ // Require the module dynamically via its ID
18
+ dynamicRequire(moduleId).increment();
19
+
20
+ // Require the module statically via its path, spelled slightly differently
21
+ const timesIncremented = require("./subdir/counter-module.js").increment();
22
+ return {
23
+ moduleId,
24
+ // Should be 2, proving there's just one module instance
25
+ timesIncremented,
26
+ };
27
+ }
28
+ module.exports = main();
@@ -0,0 +1,33 @@
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 {RequireWithResolveWeak} from './utils';
12
+
13
+ declare var require: RequireWithResolveWeak;
14
+
15
+ function main() {
16
+ const moduleId = require.resolveWeak('./subdir/counter-module');
17
+
18
+ const dynamicRequire = require;
19
+
20
+ // Require the module dynamically via its ID
21
+ dynamicRequire(moduleId).increment();
22
+
23
+ // Require the module statically via its path, spelled slightly differently
24
+ const timesIncremented = require('./subdir/counter-module.js').increment();
25
+
26
+ return {
27
+ moduleId,
28
+ // Should be 2, proving there's just one module instance
29
+ timesIncremented,
30
+ };
31
+ }
32
+
33
+ module.exports = (main(): mixed);
@@ -0,0 +1,19 @@
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
+
13
+ let count = 0;
14
+ module.exports = {
15
+ increment() {
16
+ ++count;
17
+ return count;
18
+ },
19
+ };
@@ -0,0 +1,18 @@
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
+ let count: number = 0;
12
+
13
+ module.exports = {
14
+ increment(): number {
15
+ ++count;
16
+ return count;
17
+ },
18
+ };
@@ -0,0 +1,13 @@
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
+
13
+ throw new Error("This module cannot be evaluated.");
@@ -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-local
9
+ */
10
+
11
+ throw new Error('This module cannot be evaluated.');
@@ -0,0 +1,14 @@
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
+ export type RequireWithResolveWeak = {
12
+ (id: string | number): any,
13
+ resolveWeak: (id: string) => string | number,
14
+ };
@@ -79,11 +79,7 @@ class CountingSet {
79
79
  return this.#map.size;
80
80
  }
81
81
  count(item) {
82
- var _this$map$get;
83
- return (_this$map$get = this.#map.get(item)) !== null &&
84
- _this$map$get !== void 0
85
- ? _this$map$get
86
- : 0;
82
+ return this.#map.get(item) ?? 0;
87
83
  }
88
84
  clear() {
89
85
  this.#map.clear();
@@ -24,7 +24,6 @@ const HEADER_SIZE = 3;
24
24
  * getModule(): returns the code for the specified module.
25
25
  */
26
26
  class RamBundleParser {
27
- // $FlowFixMe[missing-local-annot]
28
27
  constructor(buffer) {
29
28
  this._buffer = buffer;
30
29
  if (this._readPosition(0) !== MAGIC_NUMBER) {
@@ -29,7 +29,6 @@ class RamBundleParser {
29
29
  _startupCodeLength: number;
30
30
  _startOffset: number;
31
31
 
32
- // $FlowFixMe[missing-local-annot]
33
32
  constructor(buffer: Buffer) {
34
33
  this._buffer = buffer;
35
34
 
@@ -203,6 +203,9 @@ class TerminalReporter {
203
203
  case "global_cache_disabled":
204
204
  this._logCacheDisabled(event.reason);
205
205
  break;
206
+ case "resolver_warning":
207
+ this._logWarning(event.message);
208
+ break;
206
209
  case "transform_cache_reset":
207
210
  reporting.logWarning(this.terminal, "the transform cache was reset.");
208
211
  break;
@@ -360,31 +363,20 @@ class TerminalReporter {
360
363
  e
361
364
  );
362
365
  }
366
+ _logWarning(message) {
367
+ reporting.logWarning(this.terminal, message);
368
+ }
363
369
  _logWatcherHealthCheckResult(result) {
364
- var _result$pauseReason, _this$_prevHealthChec;
365
370
  // Don't be spammy; only report changes in status.
366
371
  if (
367
372
  !this._prevHealthCheckResult ||
368
373
  result.type !== this._prevHealthCheckResult.type ||
369
374
  (result.type === "timeout" &&
370
375
  this._prevHealthCheckResult.type === "timeout" &&
371
- ((_result$pauseReason = result.pauseReason) !== null &&
372
- _result$pauseReason !== void 0
373
- ? _result$pauseReason
374
- : null) !==
375
- ((_this$_prevHealthChec = this._prevHealthCheckResult.pauseReason) !==
376
- null && _this$_prevHealthChec !== void 0
377
- ? _this$_prevHealthChec
378
- : null))
376
+ (result.pauseReason ?? null) !==
377
+ (this._prevHealthCheckResult.pauseReason ?? null))
379
378
  ) {
380
- var _result$watcher;
381
- const watcherName =
382
- "'" +
383
- ((_result$watcher = result.watcher) !== null &&
384
- _result$watcher !== void 0
385
- ? _result$watcher
386
- : "unknown") +
387
- "'";
379
+ const watcherName = "'" + (result.watcher ?? "unknown") + "'";
388
380
  switch (result.type) {
389
381
  case "success":
390
382
  // Only report success after a prior failure.
@@ -260,6 +260,9 @@ class TerminalReporter {
260
260
  case 'global_cache_disabled':
261
261
  this._logCacheDisabled(event.reason);
262
262
  break;
263
+ case 'resolver_warning':
264
+ this._logWarning(event.message);
265
+ break;
263
266
  case 'transform_cache_reset':
264
267
  reporting.logWarning(this.terminal, 'the transform cache was reset.');
265
268
  break;
@@ -435,6 +438,10 @@ class TerminalReporter {
435
438
  );
436
439
  }
437
440
 
441
+ _logWarning(message: string): void {
442
+ reporting.logWarning(this.terminal, message);
443
+ }
444
+
438
445
  _logWatcherHealthCheckResult(result: HealthCheckResult) {
439
446
  // Don't be spammy; only report changes in status.
440
447
  if (
@@ -66,7 +66,7 @@ function createFileMap(modulePath, files, processModule) {
66
66
  .forEach((file) => {
67
67
  let filePath = path.relative(modulePath, file);
68
68
  if (os.platform() === "win32") {
69
- filePath = filePath.replace(/\\/g, "/");
69
+ filePath = filePath.replaceAll("\\", "/");
70
70
  }
71
71
 
72
72
  // NOTE(EvanBacon): I'd prefer we prevent the ability for a module to require itself (`require.context('./')`)