metro 0.82.0 → 0.82.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.82.0",
3
+ "version": "0.82.1",
4
4
  "description": "🚇 The JavaScript bundler for React Native.",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/cli.js",
@@ -42,18 +42,18 @@
42
42
  "jest-worker": "^29.7.0",
43
43
  "jsc-safe-url": "^0.2.2",
44
44
  "lodash.throttle": "^4.1.1",
45
- "metro-babel-transformer": "0.82.0",
46
- "metro-cache": "0.82.0",
47
- "metro-cache-key": "0.82.0",
48
- "metro-config": "0.82.0",
49
- "metro-core": "0.82.0",
50
- "metro-file-map": "0.82.0",
51
- "metro-resolver": "0.82.0",
52
- "metro-runtime": "0.82.0",
53
- "metro-source-map": "0.82.0",
54
- "metro-symbolicate": "0.82.0",
55
- "metro-transform-plugins": "0.82.0",
56
- "metro-transform-worker": "0.82.0",
45
+ "metro-babel-transformer": "0.82.1",
46
+ "metro-cache": "0.82.1",
47
+ "metro-cache-key": "0.82.1",
48
+ "metro-config": "0.82.1",
49
+ "metro-core": "0.82.1",
50
+ "metro-file-map": "0.82.1",
51
+ "metro-resolver": "0.82.1",
52
+ "metro-runtime": "0.82.1",
53
+ "metro-source-map": "0.82.1",
54
+ "metro-symbolicate": "0.82.1",
55
+ "metro-transform-plugins": "0.82.1",
56
+ "metro-transform-worker": "0.82.1",
57
57
  "mime-types": "^2.1.27",
58
58
  "nullthrows": "^1.1.1",
59
59
  "serialize-error": "^2.1.0",
@@ -65,14 +65,14 @@
65
65
  "devDependencies": {
66
66
  "@babel/plugin-transform-flow-strip-types": "^7.25.2",
67
67
  "@babel/plugin-transform-modules-commonjs": "^7.24.8",
68
- "@react-native/babel-preset": "0.73.16",
69
- "@react-native/metro-babel-transformer": "0.73.11",
68
+ "@react-native/babel-preset": "0.78.0",
69
+ "@react-native/metro-babel-transformer": "0.78.0",
70
70
  "babel-jest": "^29.7.0",
71
71
  "dedent": "^0.7.0",
72
72
  "jest-snapshot": "^29.7.0",
73
73
  "jest-snapshot-serializer-raw": "^1.2.0",
74
- "metro-babel-register": "0.82.0",
75
- "metro-memory-fs": "0.82.0",
74
+ "metro-babel-register": "0.82.1",
75
+ "metro-memory-fs": "0.82.1",
76
76
  "mock-req": "^0.2.0",
77
77
  "mock-res": "^0.6.0",
78
78
  "stack-trace": "^0.0.10"
@@ -36,7 +36,7 @@ export opaque type RevisionId: string = string;
36
36
  export type OutputGraph = Graph<>;
37
37
 
38
38
  type OtherOptions = $ReadOnly<{
39
- onProgress: $PropertyType<DeltaBundlerOptions<>, 'onProgress'>,
39
+ onProgress: DeltaBundlerOptions<>['onProgress'],
40
40
  shallow: boolean,
41
41
  lazy: boolean,
42
42
  }>;
@@ -38,7 +38,7 @@ export type StackFrameOutput = $ReadOnly<{
38
38
  ...IntermediateStackFrame,
39
39
  ...
40
40
  }>;
41
- type ExplodedSourceMapModule = $ElementType<ExplodedSourceMap, number>;
41
+ type ExplodedSourceMapModule = ExplodedSourceMap[number];
42
42
  type Position = {+line1Based: number, column0Based: number};
43
43
 
44
44
  function createFunctionNameGetter(
@@ -55,8 +55,7 @@ class TerminalReporter {
55
55
  chalk.reset.dim(` ${path.dirname(localPath)}/`) +
56
56
  chalk.bold(path.basename(localPath)) +
57
57
  " " +
58
- progress +
59
- "\n"
58
+ progress
60
59
  );
61
60
  }
62
61
  _logBundleBuildDone(buildID) {
@@ -241,9 +240,13 @@ class TerminalReporter {
241
240
  if (currentProgress == null) {
242
241
  return;
243
242
  }
244
- const rawRatio = transformedFileCount / totalFileCount;
245
- const conservativeRatio = Math.pow(rawRatio, 2);
246
- const ratio = Math.max(conservativeRatio, currentProgress.ratio);
243
+ const ratio = Math.min(
244
+ Math.max(
245
+ Math.pow(transformedFileCount / Math.max(totalFileCount, 10), 2),
246
+ currentProgress.ratio
247
+ ),
248
+ 0.999
249
+ );
247
250
  Object.assign(currentProgress, {
248
251
  ratio,
249
252
  transformedFileCount,
@@ -146,8 +146,7 @@ class TerminalReporter {
146
146
  chalk.reset.dim(` ${path.dirname(localPath)}/`) +
147
147
  chalk.bold(path.basename(localPath)) +
148
148
  ' ' +
149
- progress +
150
- '\n'
149
+ progress
151
150
  );
152
151
  }
153
152
 
@@ -355,9 +354,12 @@ class TerminalReporter {
355
354
  }
356
355
 
357
356
  /**
358
- * We use Math.pow(ratio, 2) to as a conservative measure of progress because
359
- * we know the `totalCount` is going to progressively increase as well. We
360
- * also prevent the ratio from going backwards.
357
+ * Because we know the `totalFileCount` is going to progressively increase
358
+ * starting with 1:
359
+ * - We use Math.max(totalFileCount, 10) to prevent the ratio to raise too
360
+ * quickly when the total file count is low. (e.g 1/2 5/6)
361
+ * - We prevent the ratio from going backwards.
362
+ * - Instead, we use Math.pow(ratio, 2) to as a conservative measure of progress.
361
363
  */
362
364
  _updateBundleProgress({
363
365
  buildID,
@@ -373,9 +375,15 @@ class TerminalReporter {
373
375
  if (currentProgress == null) {
374
376
  return;
375
377
  }
376
- const rawRatio = transformedFileCount / totalFileCount;
377
- const conservativeRatio = Math.pow(rawRatio, 2);
378
- const ratio = Math.max(conservativeRatio, currentProgress.ratio);
378
+
379
+ const ratio = Math.min(
380
+ Math.max(
381
+ Math.pow(transformedFileCount / Math.max(totalFileCount, 10), 2),
382
+ currentProgress.ratio,
383
+ ),
384
+ 0.999, // make sure not to go above 99.9% to not get rounded to 100%,
385
+ );
386
+
379
387
  Object.assign(currentProgress, {
380
388
  ratio,
381
389
  transformedFileCount,
@@ -26,10 +26,7 @@ const defaults = require('metro-config/src/defaults/defaults');
26
26
 
27
27
  async function getPrependedScripts(
28
28
  config: ConfigT,
29
- options: $Diff<
30
- TransformInputOptions,
31
- {type: $PropertyType<TransformInputOptions, 'type'>, ...},
32
- >,
29
+ options: Omit<TransformInputOptions, 'type'>,
33
30
  resolverOptions: ResolverInputOptions,
34
31
  bundler: Bundler,
35
32
  deltaBundler: DeltaBundler<>,
@@ -98,7 +98,7 @@ export type SplitBundleOptions = {
98
98
  +transformOptions: TransformInputOptions,
99
99
  +serializerOptions: SerializerOptions,
100
100
  +graphOptions: GraphOptions,
101
- +onProgress: $PropertyType<DeltaBundlerOptions<>, 'onProgress'>,
101
+ +onProgress: DeltaBundlerOptions<>['onProgress'],
102
102
  };
103
103
 
104
104
  export type ModuleGroups = {