metro-file-map 0.73.3 → 0.73.5
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 +18 -10
- package/src/ModuleMap.js +20 -137
- package/src/ModuleMap.js.flow +20 -127
- package/src/Watcher.js +35 -59
- package/src/Watcher.js.flow +40 -21
- package/src/cache/DiskCacheManager.js +3 -15
- package/src/constants.js +21 -26
- package/src/crawlers/node.js +21 -53
- package/src/crawlers/node.js.flow +12 -20
- package/src/crawlers/watchman/index.js +78 -103
- package/src/crawlers/watchman/index.js.flow +62 -44
- package/src/crawlers/watchman/planQuery.js +10 -11
- package/src/flow-types.js +1 -0
- package/src/flow-types.js.flow +73 -21
- package/src/getMockName.js +1 -6
- package/src/index.js +306 -435
- package/src/index.js.flow +233 -211
- package/src/lib/DuplicateHasteCandidatesError.js +60 -0
- package/src/lib/DuplicateHasteCandidatesError.js.flow +65 -0
- package/src/lib/checkWatchmanCapabilities.js +2 -10
- package/src/lib/deepCloneInternalData.js +4 -3
- package/src/lib/dependencyExtractor.js +12 -35
- 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 +31 -48
- package/src/watchers/FSEventsWatcher.js.flow +21 -5
- package/src/watchers/NodeWatcher.js +54 -62
- package/src/watchers/NodeWatcher.js.flow +43 -18
- 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 +24 -19
- package/src/watchers/common.js.flow +16 -1
- package/src/worker.js +24 -59
- 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
|
@@ -8,20 +8,28 @@
|
|
|
8
8
|
* @flow strict-local
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
FileData,
|
|
13
|
+
FileMetaData,
|
|
14
|
+
FileSystem,
|
|
15
|
+
Glob,
|
|
16
|
+
Path,
|
|
17
|
+
} from './flow-types';
|
|
12
18
|
|
|
13
19
|
import H from './constants';
|
|
14
20
|
import * as fastPath from './lib/fast_path';
|
|
15
21
|
import * as path from 'path';
|
|
16
22
|
import {globsToMatcher, replacePathSepForGlob} from 'jest-util';
|
|
17
23
|
|
|
18
|
-
export default class HasteFS {
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
export default class HasteFS implements FileSystem {
|
|
25
|
+
+#rootDir: Path;
|
|
26
|
+
+#files: FileData;
|
|
21
27
|
|
|
22
28
|
constructor({rootDir, files}: {rootDir: Path, files: FileData}) {
|
|
23
|
-
|
|
24
|
-
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;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
getModuleName(file: Path): ?string {
|
|
@@ -60,12 +68,12 @@ export default class HasteFS {
|
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
getFileIterator(): Iterable<Path> {
|
|
63
|
-
return this.
|
|
71
|
+
return this.#files.keys();
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
*getAbsoluteFileIterator(): Iterable<Path> {
|
|
67
75
|
for (const file of this.getFileIterator()) {
|
|
68
|
-
yield fastPath.resolve(this
|
|
76
|
+
yield fastPath.resolve(this.#rootDir, file);
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
|
|
@@ -141,7 +149,7 @@ export default class HasteFS {
|
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
_getFileData(file: Path): void | FileMetaData {
|
|
144
|
-
const relativePath = fastPath.relative(this
|
|
145
|
-
return this.
|
|
152
|
+
const relativePath = fastPath.relative(this.#rootDir, file);
|
|
153
|
+
return this.#files.get(relativePath);
|
|
146
154
|
}
|
|
147
155
|
}
|
package/src/ModuleMap.js
CHANGED
|
@@ -4,11 +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
|
-
|
|
8
|
+
var _DuplicateHasteCandidatesError = require("./lib/DuplicateHasteCandidatesError");
|
|
10
9
|
var fastPath = _interopRequireWildcard(require("./lib/fast_path"));
|
|
11
|
-
|
|
12
10
|
function _getRequireWildcardCache(nodeInterop) {
|
|
13
11
|
if (typeof WeakMap !== "function") return null;
|
|
14
12
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -17,7 +15,6 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
17
15
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
18
16
|
})(nodeInterop);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
function _interopRequireWildcard(obj, nodeInterop) {
|
|
22
19
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
20
|
return obj;
|
|
@@ -50,11 +47,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
50
47
|
}
|
|
51
48
|
return newObj;
|
|
52
49
|
}
|
|
53
|
-
|
|
54
50
|
function _interopRequireDefault(obj) {
|
|
55
51
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
/**
|
|
59
54
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
60
55
|
*
|
|
@@ -65,104 +60,53 @@ function _interopRequireDefault(obj) {
|
|
|
65
60
|
* @format
|
|
66
61
|
* @oncall react_native
|
|
67
62
|
*/
|
|
63
|
+
|
|
68
64
|
const EMPTY_OBJ = {};
|
|
69
65
|
const EMPTY_MAP = new Map();
|
|
70
|
-
|
|
71
66
|
class ModuleMap {
|
|
72
|
-
|
|
73
|
-
static _mapToArrayRecursive(map) {
|
|
74
|
-
let arr = Array.from(map);
|
|
75
|
-
|
|
76
|
-
if (arr[0] && arr[0][1] instanceof Map) {
|
|
77
|
-
arr = arr.map(
|
|
78
|
-
// $FlowFixMe[unclear-type] - Refactor away this function
|
|
79
|
-
(el) => [el[0], this._mapToArrayRecursive(el[1])]
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return arr;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static _mapFromArrayRecursive(arr) { // $FlowFixMe[unclear-type] - Refactor away this function
|
|
87
|
-
if (arr[0] && Array.isArray(arr[1])) {
|
|
88
|
-
// $FlowFixMe[reassign-const] - Refactor away this function
|
|
89
|
-
arr = arr.map((el) => [
|
|
90
|
-
el[0], // $FlowFixMe[unclear-type] - Refactor away this function
|
|
91
|
-
this._mapFromArrayRecursive(el[1]), // $FlowFixMe[unclear-type] - Refactor away this function
|
|
92
|
-
]);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return new Map(arr);
|
|
96
|
-
}
|
|
97
|
-
|
|
67
|
+
#raw;
|
|
98
68
|
constructor(raw) {
|
|
99
|
-
|
|
69
|
+
// $FlowIssue[cannot-write] - should be fixed in Flow 0.193 (D41130671)
|
|
70
|
+
this.#raw = raw;
|
|
100
71
|
}
|
|
101
|
-
|
|
102
72
|
getModule(name, platform, supportsNativePlatform, type) {
|
|
103
73
|
const module = this._getModuleMetadata(
|
|
104
74
|
name,
|
|
105
75
|
platform,
|
|
106
76
|
!!supportsNativePlatform
|
|
107
77
|
);
|
|
108
|
-
|
|
109
78
|
if (
|
|
110
79
|
module &&
|
|
111
80
|
module[_constants.default.TYPE] ===
|
|
112
81
|
(type !== null && type !== void 0 ? type : _constants.default.MODULE)
|
|
113
82
|
) {
|
|
114
83
|
const modulePath = module[_constants.default.PATH];
|
|
115
|
-
return modulePath && fastPath.resolve(this.
|
|
84
|
+
return modulePath && fastPath.resolve(this.#raw.rootDir, modulePath);
|
|
116
85
|
}
|
|
117
|
-
|
|
118
86
|
return null;
|
|
119
87
|
}
|
|
120
|
-
|
|
121
88
|
getPackage(name, platform, _supportsNativePlatform) {
|
|
122
89
|
return this.getModule(name, platform, null, _constants.default.PACKAGE);
|
|
123
90
|
}
|
|
124
|
-
|
|
125
91
|
getMockModule(name) {
|
|
126
92
|
const mockPath =
|
|
127
|
-
this.
|
|
128
|
-
|
|
93
|
+
this.#raw.mocks.get(name) || this.#raw.mocks.get(name + "/index");
|
|
129
94
|
return mockPath != null
|
|
130
|
-
? fastPath.resolve(this.
|
|
95
|
+
? fastPath.resolve(this.#raw.rootDir, mockPath)
|
|
131
96
|
: null;
|
|
132
97
|
}
|
|
133
98
|
|
|
99
|
+
// FIXME: This is only used by Meta-internal validation and should be
|
|
100
|
+
// removed or replaced with a less leaky API.
|
|
134
101
|
getRawModuleMap() {
|
|
135
102
|
return {
|
|
136
|
-
duplicates: this.
|
|
137
|
-
map: this.
|
|
138
|
-
mocks: this.
|
|
139
|
-
rootDir: this.
|
|
103
|
+
duplicates: this.#raw.duplicates,
|
|
104
|
+
map: this.#raw.map,
|
|
105
|
+
mocks: this.#raw.mocks,
|
|
106
|
+
rootDir: this.#raw.rootDir,
|
|
140
107
|
};
|
|
141
108
|
}
|
|
142
109
|
|
|
143
|
-
toJSON() {
|
|
144
|
-
if (!this._json) {
|
|
145
|
-
this._json = {
|
|
146
|
-
duplicates: ModuleMap._mapToArrayRecursive(this._raw.duplicates),
|
|
147
|
-
map: Array.from(this._raw.map),
|
|
148
|
-
mocks: Array.from(this._raw.mocks),
|
|
149
|
-
rootDir: this._raw.rootDir,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return this._json;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
static fromJSON(serializableModuleMap) {
|
|
157
|
-
return new ModuleMap({
|
|
158
|
-
duplicates: ModuleMap._mapFromArrayRecursive(
|
|
159
|
-
serializableModuleMap.duplicates
|
|
160
|
-
),
|
|
161
|
-
map: new Map(serializableModuleMap.map),
|
|
162
|
-
mocks: new Map(serializableModuleMap.mocks),
|
|
163
|
-
rootDir: serializableModuleMap.rootDir,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
110
|
/**
|
|
167
111
|
* When looking up a module's data, we walk through each eligible platform for
|
|
168
112
|
* the query. For each platform, we want to check if there are known
|
|
@@ -171,11 +115,9 @@ class ModuleMap {
|
|
|
171
115
|
* extra sure. If metadata exists both in the `duplicates` object and the
|
|
172
116
|
* `map`, this would be a bug.
|
|
173
117
|
*/
|
|
174
|
-
|
|
175
118
|
_getModuleMetadata(name, platform, supportsNativePlatform) {
|
|
176
|
-
const map = this.
|
|
177
|
-
const dupMap = this.
|
|
178
|
-
|
|
119
|
+
const map = this.#raw.map.get(name) || EMPTY_OBJ;
|
|
120
|
+
const dupMap = this.#raw.duplicates.get(name) || EMPTY_MAP;
|
|
179
121
|
if (platform != null) {
|
|
180
122
|
this._assertNoDuplicates(
|
|
181
123
|
name,
|
|
@@ -183,12 +125,10 @@ class ModuleMap {
|
|
|
183
125
|
supportsNativePlatform,
|
|
184
126
|
dupMap.get(platform)
|
|
185
127
|
);
|
|
186
|
-
|
|
187
128
|
if (map[platform] != null) {
|
|
188
129
|
return map[platform];
|
|
189
130
|
}
|
|
190
131
|
}
|
|
191
|
-
|
|
192
132
|
if (supportsNativePlatform) {
|
|
193
133
|
this._assertNoDuplicates(
|
|
194
134
|
name,
|
|
@@ -196,47 +136,37 @@ class ModuleMap {
|
|
|
196
136
|
supportsNativePlatform,
|
|
197
137
|
dupMap.get(_constants.default.NATIVE_PLATFORM)
|
|
198
138
|
);
|
|
199
|
-
|
|
200
139
|
if (map[_constants.default.NATIVE_PLATFORM]) {
|
|
201
140
|
return map[_constants.default.NATIVE_PLATFORM];
|
|
202
141
|
}
|
|
203
142
|
}
|
|
204
|
-
|
|
205
143
|
this._assertNoDuplicates(
|
|
206
144
|
name,
|
|
207
145
|
_constants.default.GENERIC_PLATFORM,
|
|
208
146
|
supportsNativePlatform,
|
|
209
147
|
dupMap.get(_constants.default.GENERIC_PLATFORM)
|
|
210
148
|
);
|
|
211
|
-
|
|
212
149
|
if (map[_constants.default.GENERIC_PLATFORM]) {
|
|
213
150
|
return map[_constants.default.GENERIC_PLATFORM];
|
|
214
151
|
}
|
|
215
|
-
|
|
216
152
|
return null;
|
|
217
153
|
}
|
|
218
|
-
|
|
219
154
|
_assertNoDuplicates(name, platform, supportsNativePlatform, relativePathSet) {
|
|
220
155
|
if (relativePathSet == null) {
|
|
221
156
|
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const previousSet = relativePathSet;
|
|
157
|
+
}
|
|
225
158
|
const duplicates = new Map();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const duplicatePath = fastPath.resolve(this._raw.rootDir, relativePath);
|
|
159
|
+
for (const [relativePath, type] of relativePathSet) {
|
|
160
|
+
const duplicatePath = fastPath.resolve(this.#raw.rootDir, relativePath);
|
|
229
161
|
duplicates.set(duplicatePath, type);
|
|
230
162
|
}
|
|
231
|
-
|
|
232
|
-
throw new DuplicateHasteCandidatesError(
|
|
163
|
+
throw new _DuplicateHasteCandidatesError.DuplicateHasteCandidatesError(
|
|
233
164
|
name,
|
|
234
165
|
platform,
|
|
235
166
|
supportsNativePlatform,
|
|
236
167
|
duplicates
|
|
237
168
|
);
|
|
238
169
|
}
|
|
239
|
-
|
|
240
170
|
static create(rootDir) {
|
|
241
171
|
return new ModuleMap({
|
|
242
172
|
duplicates: new Map(),
|
|
@@ -246,51 +176,4 @@ class ModuleMap {
|
|
|
246
176
|
});
|
|
247
177
|
}
|
|
248
178
|
}
|
|
249
|
-
|
|
250
179
|
exports.default = ModuleMap;
|
|
251
|
-
|
|
252
|
-
class DuplicateHasteCandidatesError extends Error {
|
|
253
|
-
constructor(name, platform, supportsNativePlatform, duplicatesSet) {
|
|
254
|
-
const platformMessage = getPlatformMessage(platform);
|
|
255
|
-
super(
|
|
256
|
-
`The name \`${name}\` was looked up in the Haste module map. It ` +
|
|
257
|
-
"cannot be resolved, because there exists several different " +
|
|
258
|
-
"files, or packages, that provide a module for " +
|
|
259
|
-
`that particular name and platform. ${platformMessage} You must ` +
|
|
260
|
-
"delete or exclude files until there remains only one of these:\n\n" +
|
|
261
|
-
Array.from(duplicatesSet)
|
|
262
|
-
.map(
|
|
263
|
-
([dupFilePath, dupFileType]) =>
|
|
264
|
-
` * \`${dupFilePath}\` (${getTypeMessage(dupFileType)})\n`
|
|
265
|
-
)
|
|
266
|
-
.sort()
|
|
267
|
-
.join("")
|
|
268
|
-
);
|
|
269
|
-
this.hasteName = name;
|
|
270
|
-
this.platform = platform;
|
|
271
|
-
this.supportsNativePlatform = supportsNativePlatform;
|
|
272
|
-
this.duplicatesSet = duplicatesSet;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function getPlatformMessage(platform) {
|
|
277
|
-
if (platform === _constants.default.GENERIC_PLATFORM) {
|
|
278
|
-
return "The platform is generic (no extension).";
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return `The platform extension is \`${platform}\`.`;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function getTypeMessage(type) {
|
|
285
|
-
switch (type) {
|
|
286
|
-
case _constants.default.MODULE:
|
|
287
|
-
return "module";
|
|
288
|
-
|
|
289
|
-
case _constants.default.PACKAGE:
|
|
290
|
-
return "package";
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return "unknown";
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
ModuleMap.DuplicateHasteCandidatesError = DuplicateHasteCandidatesError;
|