metro 0.80.3 → 0.80.4

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.80.3",
3
+ "version": "0.80.4",
4
4
  "description": "🚇 The JavaScript bundler for React Native.",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/cli.js",
@@ -34,19 +34,19 @@
34
34
  "jest-worker": "^29.6.3",
35
35
  "jsc-safe-url": "^0.2.2",
36
36
  "lodash.throttle": "^4.1.1",
37
- "metro-babel-transformer": "0.80.3",
38
- "metro-cache": "0.80.3",
39
- "metro-cache-key": "0.80.3",
40
- "metro-config": "0.80.3",
41
- "metro-core": "0.80.3",
42
- "metro-file-map": "0.80.3",
43
- "metro-minify-terser": "0.80.3",
44
- "metro-resolver": "0.80.3",
45
- "metro-runtime": "0.80.3",
46
- "metro-source-map": "0.80.3",
47
- "metro-symbolicate": "0.80.3",
48
- "metro-transform-plugins": "0.80.3",
49
- "metro-transform-worker": "0.80.3",
37
+ "metro-babel-transformer": "0.80.4",
38
+ "metro-cache": "0.80.4",
39
+ "metro-cache-key": "0.80.4",
40
+ "metro-config": "0.80.4",
41
+ "metro-core": "0.80.4",
42
+ "metro-file-map": "0.80.4",
43
+ "metro-minify-terser": "0.80.4",
44
+ "metro-resolver": "0.80.4",
45
+ "metro-runtime": "0.80.4",
46
+ "metro-source-map": "0.80.4",
47
+ "metro-symbolicate": "0.80.4",
48
+ "metro-transform-plugins": "0.80.4",
49
+ "metro-transform-worker": "0.80.4",
50
50
  "mime-types": "^2.1.27",
51
51
  "node-fetch": "^2.2.0",
52
52
  "nullthrows": "^1.1.1",
@@ -67,8 +67,8 @@
67
67
  "dedent": "^0.7.0",
68
68
  "jest-snapshot": "^29.6.3",
69
69
  "jest-snapshot-serializer-raw": "^1.2.0",
70
- "metro-babel-register": "0.80.3",
71
- "metro-memory-fs": "0.80.3",
70
+ "metro-babel-register": "0.80.4",
71
+ "metro-memory-fs": "0.80.4",
72
72
  "mock-req": "^0.2.0",
73
73
  "mock-res": "^0.6.0",
74
74
  "stack-trace": "^0.0.10"
@@ -318,7 +318,7 @@ class Graph {
318
318
  }
319
319
  }
320
320
 
321
- // Diff dependencies (1/2): remove dependencies that have changed or been removed.
321
+ // Diff dependencies (1/3): remove dependencies that have changed or been removed.
322
322
  let dependenciesRemoved = false;
323
323
  for (const [key, prevDependency] of previousDependencies) {
324
324
  const curDependency = currentDependencies.get(key);
@@ -331,7 +331,7 @@ class Graph {
331
331
  }
332
332
  }
333
333
 
334
- // Diff dependencies (2/2): add dependencies that have changed or been added.
334
+ // Diff dependencies (2/3): add dependencies that have changed or been added.
335
335
  let dependenciesAdded = false;
336
336
  if (!commitOptions.onlyRemove) {
337
337
  for (const [key, curDependency] of currentDependencies) {
@@ -352,11 +352,21 @@ class Graph {
352
352
  }
353
353
  }
354
354
  }
355
+
356
+ // Diff dependencies (3/3): detect changes in the ordering of dependency
357
+ // keys, which must be committed even if no other changes were made.
358
+ const previousDependencyKeys = [...previousDependencies.keys()];
359
+ const dependencyKeysChangedOrReordered =
360
+ currentDependencies.size !== previousDependencies.size ||
361
+ [...currentDependencies.keys()].some(
362
+ (currentKey, index) => currentKey !== previousDependencyKeys[index]
363
+ );
355
364
  if (
356
365
  previousModule != null &&
357
366
  !transformOutputMayDiffer(previousModule, nextModule) &&
358
367
  !dependenciesRemoved &&
359
- !dependenciesAdded
368
+ !dependenciesAdded &&
369
+ !dependencyKeysChangedOrReordered
360
370
  ) {
361
371
  // We have not operated on nextModule, so restore previousModule
362
372
  // to aid diffing. Don't add this path to delta.touched.
@@ -421,7 +421,7 @@ export class Graph<T = MixedOutput> {
421
421
  }
422
422
  }
423
423
 
424
- // Diff dependencies (1/2): remove dependencies that have changed or been removed.
424
+ // Diff dependencies (1/3): remove dependencies that have changed or been removed.
425
425
  let dependenciesRemoved = false;
426
426
  for (const [key, prevDependency] of previousDependencies) {
427
427
  const curDependency = currentDependencies.get(key);
@@ -434,7 +434,7 @@ export class Graph<T = MixedOutput> {
434
434
  }
435
435
  }
436
436
 
437
- // Diff dependencies (2/2): add dependencies that have changed or been added.
437
+ // Diff dependencies (2/3): add dependencies that have changed or been added.
438
438
  let dependenciesAdded = false;
439
439
  if (!commitOptions.onlyRemove) {
440
440
  for (const [key, curDependency] of currentDependencies) {
@@ -456,11 +456,21 @@ export class Graph<T = MixedOutput> {
456
456
  }
457
457
  }
458
458
 
459
+ // Diff dependencies (3/3): detect changes in the ordering of dependency
460
+ // keys, which must be committed even if no other changes were made.
461
+ const previousDependencyKeys = [...previousDependencies.keys()];
462
+ const dependencyKeysChangedOrReordered =
463
+ currentDependencies.size !== previousDependencies.size ||
464
+ [...currentDependencies.keys()].some(
465
+ (currentKey, index) => currentKey !== previousDependencyKeys[index],
466
+ );
467
+
459
468
  if (
460
469
  previousModule != null &&
461
470
  !transformOutputMayDiffer(previousModule, nextModule) &&
462
471
  !dependenciesRemoved &&
463
- !dependenciesAdded
472
+ !dependenciesAdded &&
473
+ !dependencyKeysChangedOrReordered
464
474
  ) {
465
475
  // We have not operated on nextModule, so restore previousModule
466
476
  // to aid diffing. Don't add this path to delta.touched.
@@ -190,14 +190,6 @@ class DependencyGraph extends EventEmitter {
190
190
  return nullthrows(this._fileSystem).getAllFiles();
191
191
  }
192
192
  getSha1(filename) {
193
- // TODO If it looks like we're trying to get the sha1 from a file located
194
- // within a Zip archive, then we instead compute the sha1 for what looks
195
- // like the Zip archive itself.
196
-
197
- const splitIndex = filename.indexOf(".zip/");
198
- const containerName =
199
- splitIndex !== -1 ? filename.slice(0, splitIndex + 4) : filename;
200
-
201
193
  // Prior to unstable_enableSymlinks:
202
194
  // Calling realpath allows us to get a hash for a given path even when
203
195
  // it's a symlink to a file, which prevents Metro from crashing in such a
@@ -208,8 +200,8 @@ class DependencyGraph extends EventEmitter {
208
200
  //
209
201
  // This is unnecessary with a symlink-aware fileSystem implementation.
210
202
  const resolvedPath = this._config.resolver.unstable_enableSymlinks
211
- ? containerName
212
- : fs.realpathSync(containerName);
203
+ ? filename
204
+ : fs.realpathSync(filename);
213
205
  const sha1 = this._fileSystem.getSha1(resolvedPath);
214
206
  if (!sha1) {
215
207
  throw new ReferenceError(`SHA-1 for file ${filename} (${resolvedPath}) is not computed.
@@ -248,14 +248,6 @@ class DependencyGraph extends EventEmitter {
248
248
  }
249
249
 
250
250
  getSha1(filename: string): string {
251
- // TODO If it looks like we're trying to get the sha1 from a file located
252
- // within a Zip archive, then we instead compute the sha1 for what looks
253
- // like the Zip archive itself.
254
-
255
- const splitIndex = filename.indexOf('.zip/');
256
- const containerName =
257
- splitIndex !== -1 ? filename.slice(0, splitIndex + 4) : filename;
258
-
259
251
  // Prior to unstable_enableSymlinks:
260
252
  // Calling realpath allows us to get a hash for a given path even when
261
253
  // it's a symlink to a file, which prevents Metro from crashing in such a
@@ -266,8 +258,8 @@ class DependencyGraph extends EventEmitter {
266
258
  //
267
259
  // This is unnecessary with a symlink-aware fileSystem implementation.
268
260
  const resolvedPath = this._config.resolver.unstable_enableSymlinks
269
- ? containerName
270
- : fs.realpathSync(containerName);
261
+ ? filename
262
+ : fs.realpathSync(filename);
271
263
 
272
264
  const sha1 = this._fileSystem.getSha1(resolvedPath);
273
265