metro-file-map 0.73.4 → 0.73.6
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 +1 -1
- package/src/HasteFS.js +16 -43
- package/src/HasteFS.js.flow +10 -8
- package/src/ModuleMap.js +20 -44
- package/src/ModuleMap.js.flow +16 -16
- package/src/Watcher.js +10 -56
- package/src/Watcher.js.flow +12 -7
- package/src/cache/DiskCacheManager.js +3 -15
- package/src/constants.js +21 -26
- package/src/crawlers/node.js +8 -41
- package/src/crawlers/watchman/index.js +22 -68
- package/src/crawlers/watchman/index.js.flow +9 -5
- package/src/crawlers/watchman/planQuery.js +10 -11
- package/src/flow-types.js +1 -0
- package/src/flow-types.js.flow +20 -5
- package/src/getMockName.js +1 -6
- package/src/index.js +90 -227
- package/src/index.js.flow +40 -28
- package/src/lib/DuplicateHasteCandidatesError.js +1 -9
- package/src/lib/checkWatchmanCapabilities.js +2 -10
- package/src/lib/deepCloneInternalData.js +4 -3
- package/src/lib/dependencyExtractor.js +12 -36
- package/src/lib/fast_path.js +3 -6
- package/src/lib/getPlatformExtension.js +5 -6
- package/src/lib/normalizePathSep.js +1 -6
- package/src/lib/rootRelativeCacheKeys.js +6 -13
- package/src/watchers/FSEventsWatcher.js +35 -46
- package/src/watchers/FSEventsWatcher.js.flow +21 -5
- package/src/watchers/NodeWatcher.js +110 -105
- package/src/watchers/NodeWatcher.js.flow +103 -62
- package/src/watchers/RecrawlWarning.js +1 -11
- package/src/watchers/WatchmanWatcher.js +42 -84
- package/src/watchers/WatchmanWatcher.js.flow +35 -29
- package/src/watchers/common.js +28 -26
- package/src/watchers/common.js.flow +16 -2
- package/src/worker.js +20 -52
- package/src/worker.js.flow +1 -1
- package/src/workerExclusionList.js +41 -37
package/package.json
CHANGED
package/src/HasteFS.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _constants = _interopRequireDefault(require("./constants"));
|
|
9
|
-
|
|
10
8
|
var fastPath = _interopRequireWildcard(require("./lib/fast_path"));
|
|
11
|
-
|
|
12
9
|
var path = _interopRequireWildcard(require("path"));
|
|
13
|
-
|
|
14
10
|
var _jestUtil = require("jest-util");
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) {
|
|
17
12
|
if (typeof WeakMap !== "function") return null;
|
|
18
13
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -21,7 +16,6 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
21
16
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
17
|
})(nodeInterop);
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
function _interopRequireWildcard(obj, nodeInterop) {
|
|
26
20
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
21
|
return obj;
|
|
@@ -54,11 +48,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
54
48
|
}
|
|
55
49
|
return newObj;
|
|
56
50
|
}
|
|
57
|
-
|
|
58
51
|
function _interopRequireDefault(obj) {
|
|
59
52
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
/**
|
|
63
55
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
64
56
|
*
|
|
@@ -68,27 +60,26 @@ function _interopRequireDefault(obj) {
|
|
|
68
60
|
* @format
|
|
69
61
|
*
|
|
70
62
|
*/
|
|
63
|
+
|
|
71
64
|
class HasteFS {
|
|
65
|
+
#rootDir;
|
|
66
|
+
#files;
|
|
72
67
|
constructor({ rootDir, files }) {
|
|
73
|
-
|
|
74
|
-
this
|
|
68
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
69
|
+
this.#rootDir = rootDir;
|
|
70
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
71
|
+
this.#files = files;
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
getModuleName(file) {
|
|
78
74
|
const fileMetadata = this._getFileData(file);
|
|
79
|
-
|
|
80
75
|
return (fileMetadata && fileMetadata[_constants.default.ID]) || null;
|
|
81
76
|
}
|
|
82
|
-
|
|
83
77
|
getSize(file) {
|
|
84
78
|
const fileMetadata = this._getFileData(file);
|
|
85
|
-
|
|
86
79
|
return (fileMetadata && fileMetadata[_constants.default.SIZE]) || null;
|
|
87
80
|
}
|
|
88
|
-
|
|
89
81
|
getDependencies(file) {
|
|
90
82
|
const fileMetadata = this._getFileData(file);
|
|
91
|
-
|
|
92
83
|
if (fileMetadata) {
|
|
93
84
|
return fileMetadata[_constants.default.DEPENDENCIES]
|
|
94
85
|
? fileMetadata[_constants.default.DEPENDENCIES].split(
|
|
@@ -99,71 +90,60 @@ class HasteFS {
|
|
|
99
90
|
return null;
|
|
100
91
|
}
|
|
101
92
|
}
|
|
102
|
-
|
|
103
93
|
getSha1(file) {
|
|
104
94
|
var _ref;
|
|
105
|
-
|
|
106
95
|
const fileMetadata = this._getFileData(file);
|
|
107
|
-
|
|
108
96
|
return (_ref = fileMetadata && fileMetadata[_constants.default.SHA1]) !==
|
|
109
97
|
null && _ref !== void 0
|
|
110
98
|
? _ref
|
|
111
99
|
: null;
|
|
112
100
|
}
|
|
113
|
-
|
|
114
101
|
exists(file) {
|
|
115
102
|
return this._getFileData(file) != null;
|
|
116
103
|
}
|
|
117
|
-
|
|
118
104
|
getAllFiles() {
|
|
119
105
|
return Array.from(this.getAbsoluteFileIterator());
|
|
120
106
|
}
|
|
121
|
-
|
|
122
107
|
getFileIterator() {
|
|
123
|
-
return this.
|
|
108
|
+
return this.#files.keys();
|
|
124
109
|
}
|
|
125
|
-
|
|
126
110
|
*getAbsoluteFileIterator() {
|
|
127
111
|
for (const file of this.getFileIterator()) {
|
|
128
|
-
yield fastPath.resolve(this
|
|
112
|
+
yield fastPath.resolve(this.#rootDir, file);
|
|
129
113
|
}
|
|
130
114
|
}
|
|
131
|
-
|
|
132
115
|
matchFiles(pattern) {
|
|
133
116
|
const regexpPattern =
|
|
134
117
|
pattern instanceof RegExp ? pattern : new RegExp(pattern);
|
|
135
118
|
const files = [];
|
|
136
|
-
|
|
137
119
|
for (const file of this.getAbsoluteFileIterator()) {
|
|
138
120
|
if (regexpPattern.test(file)) {
|
|
139
121
|
files.push(file);
|
|
140
122
|
}
|
|
141
123
|
}
|
|
142
|
-
|
|
143
124
|
return files;
|
|
144
125
|
}
|
|
126
|
+
|
|
145
127
|
/**
|
|
146
128
|
* Given a search context, return a list of file paths matching the query.
|
|
147
129
|
* The query matches against normalized paths which start with `./`,
|
|
148
130
|
* for example: `a/b.js` -> `./a/b.js`
|
|
149
131
|
*/
|
|
150
|
-
|
|
151
132
|
matchFilesWithContext(root, context) {
|
|
152
133
|
const files = [];
|
|
153
134
|
const prefix = "./";
|
|
154
|
-
|
|
155
135
|
for (const file of this.getAbsoluteFileIterator()) {
|
|
156
136
|
const filePath = fastPath.relative(root, file);
|
|
157
|
-
const isUnderRoot = filePath && !filePath.startsWith("..");
|
|
158
|
-
|
|
137
|
+
const isUnderRoot = filePath && !filePath.startsWith("..");
|
|
138
|
+
// Ignore everything outside of the provided `root`.
|
|
159
139
|
if (!isUnderRoot) {
|
|
160
140
|
continue;
|
|
161
|
-
}
|
|
141
|
+
}
|
|
162
142
|
|
|
143
|
+
// Prevent searching in child directories during a non-recursive search.
|
|
163
144
|
if (!context.recursive && filePath.includes(path.sep)) {
|
|
164
145
|
continue;
|
|
165
146
|
}
|
|
166
|
-
|
|
167
147
|
if (
|
|
168
148
|
context.filter.test(
|
|
169
149
|
// NOTE(EvanBacon): Ensure files start with `./` for matching purposes
|
|
@@ -175,29 +155,22 @@ class HasteFS {
|
|
|
175
155
|
files.push(file);
|
|
176
156
|
}
|
|
177
157
|
}
|
|
178
|
-
|
|
179
158
|
return files;
|
|
180
159
|
}
|
|
181
|
-
|
|
182
160
|
matchFilesWithGlob(globs, root) {
|
|
183
161
|
const files = new Set();
|
|
184
162
|
const matcher = (0, _jestUtil.globsToMatcher)(globs);
|
|
185
|
-
|
|
186
163
|
for (const file of this.getAbsoluteFileIterator()) {
|
|
187
164
|
const filePath = root != null ? fastPath.relative(root, file) : file;
|
|
188
|
-
|
|
189
165
|
if (matcher((0, _jestUtil.replacePathSepForGlob)(filePath))) {
|
|
190
166
|
files.add(file);
|
|
191
167
|
}
|
|
192
168
|
}
|
|
193
|
-
|
|
194
169
|
return files;
|
|
195
170
|
}
|
|
196
|
-
|
|
197
171
|
_getFileData(file) {
|
|
198
|
-
const relativePath = fastPath.relative(this
|
|
199
|
-
return this.
|
|
172
|
+
const relativePath = fastPath.relative(this.#rootDir, file);
|
|
173
|
+
return this.#files.get(relativePath);
|
|
200
174
|
}
|
|
201
175
|
}
|
|
202
|
-
|
|
203
176
|
exports.default = HasteFS;
|
package/src/HasteFS.js.flow
CHANGED
|
@@ -22,12 +22,14 @@ import * as path from 'path';
|
|
|
22
22
|
import {globsToMatcher, replacePathSepForGlob} from 'jest-util';
|
|
23
23
|
|
|
24
24
|
export default class HasteFS implements FileSystem {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
+#rootDir: Path;
|
|
26
|
+
+#files: FileData;
|
|
27
27
|
|
|
28
28
|
constructor({rootDir, files}: {rootDir: Path, files: FileData}) {
|
|
29
|
-
|
|
30
|
-
this
|
|
29
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
30
|
+
this.#rootDir = rootDir;
|
|
31
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
32
|
+
this.#files = files;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
getModuleName(file: Path): ?string {
|
|
@@ -66,12 +68,12 @@ export default class HasteFS implements FileSystem {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
getFileIterator(): Iterable<Path> {
|
|
69
|
-
return this.
|
|
71
|
+
return this.#files.keys();
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
*getAbsoluteFileIterator(): Iterable<Path> {
|
|
73
75
|
for (const file of this.getFileIterator()) {
|
|
74
|
-
yield fastPath.resolve(this
|
|
76
|
+
yield fastPath.resolve(this.#rootDir, file);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
|
|
@@ -147,7 +149,7 @@ export default class HasteFS implements FileSystem {
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
_getFileData(file: Path): void | FileMetaData {
|
|
150
|
-
const relativePath = fastPath.relative(this
|
|
151
|
-
return this.
|
|
152
|
+
const relativePath = fastPath.relative(this.#rootDir, file);
|
|
153
|
+
return this.#files.get(relativePath);
|
|
152
154
|
}
|
|
153
155
|
}
|
package/src/ModuleMap.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _constants = _interopRequireDefault(require("./constants"));
|
|
9
|
-
|
|
10
8
|
var _DuplicateHasteCandidatesError = require("./lib/DuplicateHasteCandidatesError");
|
|
11
|
-
|
|
12
9
|
var fastPath = _interopRequireWildcard(require("./lib/fast_path"));
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
11
|
if (typeof WeakMap !== "function") return null;
|
|
16
12
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -19,7 +15,6 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
19
15
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
16
|
})(nodeInterop);
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
function _interopRequireWildcard(obj, nodeInterop) {
|
|
24
19
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
20
|
return obj;
|
|
@@ -52,11 +47,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
52
47
|
}
|
|
53
48
|
return newObj;
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
function _interopRequireDefault(obj) {
|
|
57
51
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
/**
|
|
61
54
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
62
55
|
*
|
|
@@ -67,55 +60,53 @@ function _interopRequireDefault(obj) {
|
|
|
67
60
|
* @format
|
|
68
61
|
* @oncall react_native
|
|
69
62
|
*/
|
|
63
|
+
|
|
70
64
|
const EMPTY_OBJ = {};
|
|
71
65
|
const EMPTY_MAP = new Map();
|
|
72
|
-
|
|
73
66
|
class ModuleMap {
|
|
67
|
+
#raw;
|
|
74
68
|
constructor(raw) {
|
|
75
|
-
|
|
69
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
70
|
+
this.#raw = raw;
|
|
76
71
|
}
|
|
77
|
-
|
|
78
72
|
getModule(name, platform, supportsNativePlatform, type) {
|
|
79
73
|
const module = this._getModuleMetadata(
|
|
80
74
|
name,
|
|
81
75
|
platform,
|
|
82
76
|
!!supportsNativePlatform
|
|
83
77
|
);
|
|
84
|
-
|
|
85
78
|
if (
|
|
86
79
|
module &&
|
|
87
80
|
module[_constants.default.TYPE] ===
|
|
88
81
|
(type !== null && type !== void 0 ? type : _constants.default.MODULE)
|
|
89
82
|
) {
|
|
90
83
|
const modulePath = module[_constants.default.PATH];
|
|
91
|
-
return modulePath && fastPath.resolve(this.
|
|
84
|
+
return modulePath && fastPath.resolve(this.#raw.rootDir, modulePath);
|
|
92
85
|
}
|
|
93
|
-
|
|
94
86
|
return null;
|
|
95
87
|
}
|
|
96
|
-
|
|
97
88
|
getPackage(name, platform, _supportsNativePlatform) {
|
|
98
89
|
return this.getModule(name, platform, null, _constants.default.PACKAGE);
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
getMockModule(name) {
|
|
102
92
|
const mockPath =
|
|
103
|
-
this.
|
|
104
|
-
|
|
93
|
+
this.#raw.mocks.get(name) || this.#raw.mocks.get(name + "/index");
|
|
105
94
|
return mockPath != null
|
|
106
|
-
? fastPath.resolve(this.
|
|
95
|
+
? fastPath.resolve(this.#raw.rootDir, mockPath)
|
|
107
96
|
: null;
|
|
108
|
-
}
|
|
109
|
-
// removed or replaced with a less leaky API.
|
|
97
|
+
}
|
|
110
98
|
|
|
99
|
+
// FIXME: This is only used by Meta-internal validation and should be
|
|
100
|
+
// removed or replaced with a less leaky API.
|
|
111
101
|
getRawModuleMap() {
|
|
112
102
|
return {
|
|
113
|
-
duplicates: this.
|
|
114
|
-
map: this.
|
|
115
|
-
mocks: this.
|
|
116
|
-
rootDir: this.
|
|
103
|
+
duplicates: this.#raw.duplicates,
|
|
104
|
+
map: this.#raw.map,
|
|
105
|
+
mocks: this.#raw.mocks,
|
|
106
|
+
rootDir: this.#raw.rootDir,
|
|
117
107
|
};
|
|
118
108
|
}
|
|
109
|
+
|
|
119
110
|
/**
|
|
120
111
|
* When looking up a module's data, we walk through each eligible platform for
|
|
121
112
|
* the query. For each platform, we want to check if there are known
|
|
@@ -124,11 +115,9 @@ class ModuleMap {
|
|
|
124
115
|
* extra sure. If metadata exists both in the `duplicates` object and the
|
|
125
116
|
* `map`, this would be a bug.
|
|
126
117
|
*/
|
|
127
|
-
|
|
128
118
|
_getModuleMetadata(name, platform, supportsNativePlatform) {
|
|
129
|
-
const map = this.
|
|
130
|
-
const dupMap = this.
|
|
131
|
-
|
|
119
|
+
const map = this.#raw.map.get(name) || EMPTY_OBJ;
|
|
120
|
+
const dupMap = this.#raw.duplicates.get(name) || EMPTY_MAP;
|
|
132
121
|
if (platform != null) {
|
|
133
122
|
this._assertNoDuplicates(
|
|
134
123
|
name,
|
|
@@ -136,12 +125,10 @@ class ModuleMap {
|
|
|
136
125
|
supportsNativePlatform,
|
|
137
126
|
dupMap.get(platform)
|
|
138
127
|
);
|
|
139
|
-
|
|
140
128
|
if (map[platform] != null) {
|
|
141
129
|
return map[platform];
|
|
142
130
|
}
|
|
143
131
|
}
|
|
144
|
-
|
|
145
132
|
if (supportsNativePlatform) {
|
|
146
133
|
this._assertNoDuplicates(
|
|
147
134
|
name,
|
|
@@ -149,39 +136,30 @@ class ModuleMap {
|
|
|
149
136
|
supportsNativePlatform,
|
|
150
137
|
dupMap.get(_constants.default.NATIVE_PLATFORM)
|
|
151
138
|
);
|
|
152
|
-
|
|
153
139
|
if (map[_constants.default.NATIVE_PLATFORM]) {
|
|
154
140
|
return map[_constants.default.NATIVE_PLATFORM];
|
|
155
141
|
}
|
|
156
142
|
}
|
|
157
|
-
|
|
158
143
|
this._assertNoDuplicates(
|
|
159
144
|
name,
|
|
160
145
|
_constants.default.GENERIC_PLATFORM,
|
|
161
146
|
supportsNativePlatform,
|
|
162
147
|
dupMap.get(_constants.default.GENERIC_PLATFORM)
|
|
163
148
|
);
|
|
164
|
-
|
|
165
149
|
if (map[_constants.default.GENERIC_PLATFORM]) {
|
|
166
150
|
return map[_constants.default.GENERIC_PLATFORM];
|
|
167
151
|
}
|
|
168
|
-
|
|
169
152
|
return null;
|
|
170
153
|
}
|
|
171
|
-
|
|
172
154
|
_assertNoDuplicates(name, platform, supportsNativePlatform, relativePathSet) {
|
|
173
155
|
if (relativePathSet == null) {
|
|
174
156
|
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const previousSet = relativePathSet;
|
|
157
|
+
}
|
|
178
158
|
const duplicates = new Map();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const duplicatePath = fastPath.resolve(this._raw.rootDir, relativePath);
|
|
159
|
+
for (const [relativePath, type] of relativePathSet) {
|
|
160
|
+
const duplicatePath = fastPath.resolve(this.#raw.rootDir, relativePath);
|
|
182
161
|
duplicates.set(duplicatePath, type);
|
|
183
162
|
}
|
|
184
|
-
|
|
185
163
|
throw new _DuplicateHasteCandidatesError.DuplicateHasteCandidatesError(
|
|
186
164
|
name,
|
|
187
165
|
platform,
|
|
@@ -189,7 +167,6 @@ class ModuleMap {
|
|
|
189
167
|
duplicates
|
|
190
168
|
);
|
|
191
169
|
}
|
|
192
|
-
|
|
193
170
|
static create(rootDir) {
|
|
194
171
|
return new ModuleMap({
|
|
195
172
|
duplicates: new Map(),
|
|
@@ -199,5 +176,4 @@ class ModuleMap {
|
|
|
199
176
|
});
|
|
200
177
|
}
|
|
201
178
|
}
|
|
202
|
-
|
|
203
179
|
exports.default = ModuleMap;
|
package/src/ModuleMap.js.flow
CHANGED
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
ModuleMetaData,
|
|
17
17
|
Path,
|
|
18
18
|
RawModuleMap,
|
|
19
|
+
ReadOnlyRawModuleMap,
|
|
19
20
|
} from './flow-types';
|
|
20
21
|
|
|
21
22
|
import H from './constants';
|
|
@@ -26,10 +27,11 @@ const EMPTY_OBJ: {[string]: ModuleMetaData} = {};
|
|
|
26
27
|
const EMPTY_MAP = new Map<'g' | 'native' | string, ?DuplicatesSet>();
|
|
27
28
|
|
|
28
29
|
export default class ModuleMap implements IModuleMap {
|
|
29
|
-
|
|
30
|
+
+#raw: RawModuleMap;
|
|
30
31
|
|
|
31
32
|
constructor(raw: RawModuleMap) {
|
|
32
|
-
|
|
33
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
34
|
+
this.#raw = raw;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
getModule(
|
|
@@ -45,7 +47,7 @@ export default class ModuleMap implements IModuleMap {
|
|
|
45
47
|
);
|
|
46
48
|
if (module && module[H.TYPE] === (type ?? H.MODULE)) {
|
|
47
49
|
const modulePath = module[H.PATH];
|
|
48
|
-
return modulePath && fastPath.resolve(this.
|
|
50
|
+
return modulePath && fastPath.resolve(this.#raw.rootDir, modulePath);
|
|
49
51
|
}
|
|
50
52
|
return null;
|
|
51
53
|
}
|
|
@@ -60,20 +62,20 @@ export default class ModuleMap implements IModuleMap {
|
|
|
60
62
|
|
|
61
63
|
getMockModule(name: string): ?Path {
|
|
62
64
|
const mockPath =
|
|
63
|
-
this.
|
|
65
|
+
this.#raw.mocks.get(name) || this.#raw.mocks.get(name + '/index');
|
|
64
66
|
return mockPath != null
|
|
65
|
-
? fastPath.resolve(this.
|
|
67
|
+
? fastPath.resolve(this.#raw.rootDir, mockPath)
|
|
66
68
|
: null;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
// FIXME: This is only used by Meta-internal validation and should be
|
|
70
72
|
// removed or replaced with a less leaky API.
|
|
71
|
-
getRawModuleMap():
|
|
73
|
+
getRawModuleMap(): ReadOnlyRawModuleMap {
|
|
72
74
|
return {
|
|
73
|
-
duplicates: this.
|
|
74
|
-
map: this.
|
|
75
|
-
mocks: this.
|
|
76
|
-
rootDir: this.
|
|
75
|
+
duplicates: this.#raw.duplicates,
|
|
76
|
+
map: this.#raw.map,
|
|
77
|
+
mocks: this.#raw.mocks,
|
|
78
|
+
rootDir: this.#raw.rootDir,
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -90,8 +92,8 @@ export default class ModuleMap implements IModuleMap {
|
|
|
90
92
|
platform: ?string,
|
|
91
93
|
supportsNativePlatform: boolean,
|
|
92
94
|
): ModuleMetaData | null {
|
|
93
|
-
const map = this.
|
|
94
|
-
const dupMap = this.
|
|
95
|
+
const map = this.#raw.map.get(name) || EMPTY_OBJ;
|
|
96
|
+
const dupMap = this.#raw.duplicates.get(name) || EMPTY_MAP;
|
|
95
97
|
if (platform != null) {
|
|
96
98
|
this._assertNoDuplicates(
|
|
97
99
|
name,
|
|
@@ -135,12 +137,10 @@ export default class ModuleMap implements IModuleMap {
|
|
|
135
137
|
if (relativePathSet == null) {
|
|
136
138
|
return;
|
|
137
139
|
}
|
|
138
|
-
// Force flow refinement
|
|
139
|
-
const previousSet = relativePathSet;
|
|
140
140
|
const duplicates = new Map<string, number>();
|
|
141
141
|
|
|
142
|
-
for (const [relativePath, type] of
|
|
143
|
-
const duplicatePath = fastPath.resolve(this.
|
|
142
|
+
for (const [relativePath, type] of relativePathSet) {
|
|
143
|
+
const duplicatePath = fastPath.resolve(this.#raw.rootDir, relativePath);
|
|
144
144
|
duplicates.set(duplicatePath, type);
|
|
145
145
|
}
|
|
146
146
|
|