metro-file-map 0.80.0 → 0.80.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro-file-map",
3
- "version": "0.80.0",
3
+ "version": "0.80.2",
4
4
  "description": "[Experimental] - 🚇 File crawling, watching and mapping for Metro",
5
5
  "main": "src/index.js",
6
6
  "repository": {
package/src/Watcher.js CHANGED
@@ -4,21 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true,
5
5
  });
6
6
  exports.Watcher = void 0;
7
- var _watchman = _interopRequireDefault(require("./crawlers/watchman"));
8
7
  var _node = _interopRequireDefault(require("./crawlers/node"));
9
- var _WatchmanWatcher = _interopRequireDefault(
10
- require("./watchers/WatchmanWatcher")
11
- );
8
+ var _watchman = _interopRequireDefault(require("./crawlers/watchman"));
9
+ var _common = require("./watchers/common");
12
10
  var _FSEventsWatcher = _interopRequireDefault(
13
11
  require("./watchers/FSEventsWatcher")
14
12
  );
15
13
  var _NodeWatcher = _interopRequireDefault(require("./watchers/NodeWatcher"));
16
- var path = _interopRequireWildcard(require("path"));
17
- var fs = _interopRequireWildcard(require("fs"));
18
- var _common = require("./watchers/common");
14
+ var _WatchmanWatcher = _interopRequireDefault(
15
+ require("./watchers/WatchmanWatcher")
16
+ );
19
17
  var _events = _interopRequireDefault(require("events"));
20
- var _perf_hooks = require("perf_hooks");
18
+ var fs = _interopRequireWildcard(require("fs"));
21
19
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
20
+ var path = _interopRequireWildcard(require("path"));
21
+ var _perf_hooks = require("perf_hooks");
22
22
  function _getRequireWildcardCache(nodeInterop) {
23
23
  if (typeof WeakMap !== "function") return null;
24
24
  var cacheBabelInterop = new WeakMap();
@@ -20,17 +20,17 @@ import type {
20
20
  import type {WatcherOptions as WatcherBackendOptions} from './watchers/common';
21
21
  import type {AbortSignal} from 'node-abort-controller';
22
22
 
23
- import watchmanCrawl from './crawlers/watchman';
24
23
  import nodeCrawl from './crawlers/node';
25
- import WatchmanWatcher from './watchers/WatchmanWatcher';
24
+ import watchmanCrawl from './crawlers/watchman';
25
+ import {ADD_EVENT, CHANGE_EVENT} from './watchers/common';
26
26
  import FSEventsWatcher from './watchers/FSEventsWatcher';
27
27
  import NodeWatcher from './watchers/NodeWatcher';
28
- import * as path from 'path';
29
- import * as fs from 'fs';
30
- import {ADD_EVENT, CHANGE_EVENT} from './watchers/common';
28
+ import WatchmanWatcher from './watchers/WatchmanWatcher';
31
29
  import EventEmitter from 'events';
32
- import {performance} from 'perf_hooks';
30
+ import * as fs from 'fs';
33
31
  import nullthrows from 'nullthrows';
32
+ import * as path from 'path';
33
+ import {performance} from 'perf_hooks';
34
34
 
35
35
  const debug = require('debug')('Metro:Watcher');
36
36
 
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var fastPath = _interopRequireWildcard(require("../../lib/fast_path"));
3
4
  var _hasNativeFindSupport = _interopRequireDefault(
4
5
  require("./hasNativeFindSupport")
5
6
  );
6
- var fastPath = _interopRequireWildcard(require("../../lib/fast_path"));
7
7
  var _child_process = require("child_process");
8
8
  var fs = _interopRequireWildcard(require("graceful-fs"));
9
9
  var _os = require("os");
10
10
  var path = _interopRequireWildcard(require("path"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : { default: obj };
13
+ }
11
14
  function _getRequireWildcardCache(nodeInterop) {
12
15
  if (typeof WeakMap !== "function") return null;
13
16
  var cacheBabelInterop = new WeakMap();
@@ -48,9 +51,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
48
51
  }
49
52
  return newObj;
50
53
  }
51
- function _interopRequireDefault(obj) {
52
- return obj && obj.__esModule ? obj : { default: obj };
53
- }
54
54
  /**
55
55
  * Copyright (c) Meta Platforms, Inc. and affiliates.
56
56
  *
@@ -16,8 +16,8 @@ import type {
16
16
  IgnoreMatcher,
17
17
  } from '../../flow-types';
18
18
 
19
- import hasNativeFindSupport from './hasNativeFindSupport';
20
19
  import * as fastPath from '../../lib/fast_path';
20
+ import hasNativeFindSupport from './hasNativeFindSupport';
21
21
  import {spawn} from 'child_process';
22
22
  import * as fs from 'graceful-fs';
23
23
  import {platform} from 'os';
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- import type {PerfLoggerFactory, RootPerfLogger, PerfLogger} from 'metro-config';
14
+ import type {PerfLogger, PerfLoggerFactory, RootPerfLogger} from 'metro-config';
15
15
  import type {AbortSignal} from 'node-abort-controller';
16
16
 
17
17
  export type {PerfLoggerFactory, PerfLogger};
package/src/index.js CHANGED
@@ -30,21 +30,21 @@ var _checkWatchmanCapabilities = _interopRequireDefault(
30
30
  );
31
31
  var _DuplicateError = require("./lib/DuplicateError");
32
32
  var fastPath = _interopRequireWildcard(require("./lib/fast_path"));
33
+ var _MockMap = _interopRequireDefault(require("./lib/MockMap"));
34
+ var _MutableHasteMap = _interopRequireDefault(require("./lib/MutableHasteMap"));
33
35
  var _normalizePathSeparatorsToSystem = _interopRequireDefault(
34
36
  require("./lib/normalizePathSeparatorsToSystem")
35
37
  );
36
38
  var _TreeFS = _interopRequireDefault(require("./lib/TreeFS"));
37
- var _MutableHasteMap = _interopRequireDefault(require("./lib/MutableHasteMap"));
38
39
  var _Watcher = require("./Watcher");
39
40
  var _worker = require("./worker");
40
41
  var _events = _interopRequireDefault(require("events"));
41
42
  var _invariant = _interopRequireDefault(require("invariant"));
42
43
  var _jestWorker = require("jest-worker");
43
- var path = _interopRequireWildcard(require("path"));
44
44
  var _nodeAbortController = require("node-abort-controller");
45
- var _perf_hooks = require("perf_hooks");
46
45
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
47
- var _MockMap = _interopRequireDefault(require("./lib/MockMap"));
46
+ var path = _interopRequireWildcard(require("path"));
47
+ var _perf_hooks = require("perf_hooks");
48
48
  var _DuplicateHasteCandidatesError = require("./lib/DuplicateHasteCandidatesError");
49
49
  function _getRequireWildcardCache(nodeInterop) {
50
50
  if (typeof WeakMap !== "function") return null;
@@ -205,7 +205,7 @@ class FileMap extends _events.default {
205
205
  super();
206
206
  if (options.perfLoggerFactory) {
207
207
  this._startupPerfLogger =
208
- options.perfLoggerFactory?.("START_UP").subSpan("hasteMap") ?? null;
208
+ options.perfLoggerFactory?.("START_UP").subSpan("fileMap") ?? null;
209
209
  this._startupPerfLogger?.point("constructor_start");
210
210
  }
211
211
 
@@ -252,6 +252,7 @@ class FileMap extends _events.default {
252
252
  };
253
253
  this._options = {
254
254
  ...buildParameters,
255
+ enableWorkerThreads: options.enableWorkerThreads ?? false,
255
256
  healthCheck: options.healthCheck,
256
257
  maxWorkers: options.maxWorkers,
257
258
  perfLoggerFactory: options.perfLoggerFactory,
@@ -722,6 +723,7 @@ class FileMap extends _events.default {
722
723
  exposedMethods: ["worker"],
723
724
  maxRetries: 3,
724
725
  numWorkers: this._options.maxWorkers,
726
+ enableWorkerThreads: this._options.enableWorkerThreads,
725
727
  forkOptions: {
726
728
  // Don't pass Node arguments down to workers. In particular, avoid
727
729
  // unnecessarily registering Babel when we're running Metro from
package/src/index.js.flow CHANGED
@@ -9,7 +9,6 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- import type {IJestWorker} from 'jest-worker';
13
12
  import type {
14
13
  BuildParameters,
15
14
  BuildResult,
@@ -19,24 +18,25 @@ import type {
19
18
  CanonicalPath,
20
19
  ChangeEvent,
21
20
  ChangeEventMetadata,
22
- CrawlerOptions,
23
21
  Console,
22
+ CrawlerOptions,
24
23
  EventsQueue,
25
24
  FileData,
26
25
  FileMetaData,
27
26
  FileSystem,
28
- HType,
29
27
  HasteMapData,
30
28
  HasteMapItem,
29
+ HType,
31
30
  MutableFileSystem,
32
31
  Path,
33
- PerfLoggerFactory,
34
32
  PerfLogger,
33
+ PerfLoggerFactory,
35
34
  RawMockMap,
36
35
  ReadOnlyRawMockMap,
37
- WorkerMetadata,
38
36
  WatchmanClocks,
37
+ WorkerMetadata,
39
38
  } from './flow-types';
39
+ import type {IJestWorker} from 'jest-worker';
40
40
 
41
41
  import {DiskCacheManager} from './cache/DiskCacheManager';
42
42
  import H from './constants';
@@ -44,19 +44,19 @@ import getMockName from './getMockName';
44
44
  import checkWatchmanCapabilities from './lib/checkWatchmanCapabilities';
45
45
  import {DuplicateError} from './lib/DuplicateError';
46
46
  import * as fastPath from './lib/fast_path';
47
+ import MockMapImpl from './lib/MockMap';
48
+ import MutableHasteMap from './lib/MutableHasteMap';
47
49
  import normalizePathSeparatorsToSystem from './lib/normalizePathSeparatorsToSystem';
48
50
  import TreeFS from './lib/TreeFS';
49
- import MutableHasteMap from './lib/MutableHasteMap';
50
51
  import {Watcher} from './Watcher';
51
52
  import {worker} from './worker';
52
53
  import EventEmitter from 'events';
53
54
  import invariant from 'invariant';
54
55
  import {Worker} from 'jest-worker';
55
- import * as path from 'path';
56
56
  import {AbortController} from 'node-abort-controller';
57
- import {performance} from 'perf_hooks';
58
57
  import nullthrows from 'nullthrows';
59
- import MockMapImpl from './lib/MockMap';
58
+ import * as path from 'path';
59
+ import {performance} from 'perf_hooks';
60
60
 
61
61
  const debug = require('debug')('Metro:FileMap');
62
62
 
@@ -77,6 +77,7 @@ export type InputOptions = $ReadOnly<{
77
77
  computeSha1?: ?boolean,
78
78
  enableHastePackages?: boolean,
79
79
  enableSymlinks?: ?boolean,
80
+ enableWorkerThreads?: ?boolean,
80
81
  extensions: $ReadOnlyArray<string>,
81
82
  forceNodeFilesystemAPI?: ?boolean,
82
83
  ignorePattern?: ?RegExp,
@@ -112,6 +113,7 @@ type HealthCheckOptions = $ReadOnly<{
112
113
 
113
114
  type InternalOptions = {
114
115
  ...BuildParameters,
116
+ enableWorkerThreads: boolean,
115
117
  healthCheck: HealthCheckOptions,
116
118
  perfLoggerFactory: ?PerfLoggerFactory,
117
119
  resetCache: ?boolean,
@@ -260,7 +262,7 @@ export default class FileMap extends EventEmitter {
260
262
 
261
263
  if (options.perfLoggerFactory) {
262
264
  this._startupPerfLogger =
263
- options.perfLoggerFactory?.('START_UP').subSpan('hasteMap') ?? null;
265
+ options.perfLoggerFactory?.('START_UP').subSpan('fileMap') ?? null;
264
266
  this._startupPerfLogger?.point('constructor_start');
265
267
  }
266
268
 
@@ -309,6 +311,7 @@ export default class FileMap extends EventEmitter {
309
311
 
310
312
  this._options = {
311
313
  ...buildParameters,
314
+ enableWorkerThreads: options.enableWorkerThreads ?? false,
312
315
  healthCheck: options.healthCheck,
313
316
  maxWorkers: options.maxWorkers,
314
317
  perfLoggerFactory: options.perfLoggerFactory,
@@ -808,6 +811,7 @@ export default class FileMap extends EventEmitter {
808
811
  exposedMethods: ['worker'],
809
812
  maxRetries: 3,
810
813
  numWorkers: this._options.maxWorkers,
814
+ enableWorkerThreads: this._options.enableWorkerThreads,
811
815
  forkOptions: {
812
816
  // Don't pass Node arguments down to workers. In particular, avoid
813
817
  // unnecessarily registering Babel when we're running Metro from
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import type {MockMap as IMockMap, Path, RawMockMap} from '../flow-types';
13
+
13
14
  import {resolve} from './fast_path';
14
15
 
15
16
  export default class MockMap implements IMockMap {
@@ -13,10 +13,10 @@ import type {
13
13
  Console,
14
14
  DuplicatesIndex,
15
15
  DuplicatesSet,
16
- HTypeValue,
17
16
  HasteMap,
18
17
  HasteMapItem,
19
18
  HasteMapItemMetaData,
19
+ HTypeValue,
20
20
  Path,
21
21
  RawHasteMap,
22
22
  ReadOnlyRawHasteMap,
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true,
5
5
  });
6
6
  exports.default = void 0;
7
+ var _common = require("./common");
7
8
  var _anymatch = _interopRequireDefault(require("anymatch"));
8
9
  var _events = _interopRequireDefault(require("events"));
9
10
  var _fs = require("fs");
10
11
  var path = _interopRequireWildcard(require("path"));
11
12
  var _walker = _interopRequireDefault(require("walker"));
12
- var _common = require("./common");
13
13
  function _getRequireWildcardCache(nodeInterop) {
14
14
  if (typeof WeakMap !== "function") return null;
15
15
  var cacheBabelInterop = new WeakMap();
@@ -13,6 +13,7 @@ import type {Stats} from 'fs';
13
13
  // $FlowFixMe[cannot-resolve-module] - Optional, Darwin only
14
14
  import type {FSEvents} from 'fsevents';
15
15
 
16
+ import {isIncluded, typeFromStat} from './common';
16
17
  // $FlowFixMe[untyped-import] - anymatch
17
18
  import anymatch from 'anymatch';
18
19
  import EventEmitter from 'events';
@@ -20,7 +21,6 @@ import {promises as fsPromises} from 'fs';
20
21
  import * as path from 'path';
21
22
  // $FlowFixMe[untyped-import] - walker
22
23
  import walker from 'walker';
23
- import {isIncluded, typeFromStat} from './common';
24
24
 
25
25
  const debug = require('debug')('Metro:FSEventsWatcher');
26
26
 
@@ -15,8 +15,8 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- import type {WatcherOptions} from './common';
19
18
  import type {ChangeEventMetadata} from '../flow-types';
19
+ import type {WatcherOptions} from './common';
20
20
  import type {FSWatcher, Stats} from 'fs';
21
21
 
22
22
  const common = require('./common');
@@ -9,15 +9,15 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- import type {WatcherOptions} from './common';
13
12
  import type {ChangeEventMetadata} from '../flow-types';
13
+ import type {WatcherOptions} from './common';
14
14
  import type {
15
15
  Client,
16
16
  WatchmanClockResponse,
17
17
  WatchmanFileChange,
18
18
  WatchmanQuery,
19
- WatchmanSubscriptionEvent,
20
19
  WatchmanSubscribeResponse,
20
+ WatchmanSubscriptionEvent,
21
21
  WatchmanWatchResponse,
22
22
  } from 'fb-watchman';
23
23
 
package/src/worker.js CHANGED
@@ -18,8 +18,8 @@ const H = require("./constants");
18
18
  const dependencyExtractor = require("./lib/dependencyExtractor");
19
19
  const excludedExtensions = require("./workerExclusionList");
20
20
  const { createHash } = require("crypto");
21
- const fs = require("graceful-fs");
22
21
  const { promises: fsPromises } = require("fs");
22
+ const fs = require("graceful-fs");
23
23
  const path = require("path");
24
24
  const PACKAGE_JSON = path.sep + "package.json";
25
25
  let hasteImpl /*: ?{getHasteName: string => ?string} */ = null;
@@ -18,8 +18,8 @@ const H = require('./constants');
18
18
  const dependencyExtractor = require('./lib/dependencyExtractor');
19
19
  const excludedExtensions = require('./workerExclusionList');
20
20
  const {createHash} = require('crypto');
21
- const fs = require('graceful-fs');
22
21
  const {promises: fsPromises} = require('fs');
22
+ const fs = require('graceful-fs');
23
23
  const path = require('path');
24
24
 
25
25
  const PACKAGE_JSON = path.sep + 'package.json';