metro 0.71.0 → 0.71.3
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 +23 -22
- package/src/Bundler.js +0 -2
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.js +2 -0
- package/src/DeltaBundler/DeltaCalculator.js.flow +2 -0
- package/src/DeltaBundler/Worker.flow.js +78 -0
- package/src/DeltaBundler/Worker.flow.js.flow +121 -0
- package/src/DeltaBundler/Worker.js +8 -66
- package/src/DeltaBundler/Worker.js.flow +8 -107
- package/src/DeltaBundler/WorkerFarm.js.flow +2 -2
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +4 -0
- package/src/DeltaBundler/graphOperations.js +382 -222
- package/src/DeltaBundler/graphOperations.js.flow +404 -232
- package/src/DeltaBundler/types.flow.js +6 -0
- package/src/DeltaBundler/types.flow.js.flow +7 -1
- package/src/DeltaBundler.js +0 -2
- package/src/DeltaBundler.js.flow +1 -1
- package/src/HmrServer.js +0 -2
- package/src/HmrServer.js.flow +1 -2
- package/src/ModuleGraph/node-haste/node-haste.flow.js +0 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -2
- package/src/ModuleGraph/node-haste/node-haste.js.flow +7 -2
- package/src/ModuleGraph/output/util.js.flow +2 -2
- package/src/ModuleGraph/silent-console.js +5 -4
- package/src/ModuleGraph/silent-console.js.flow +8 -4
- package/src/ModuleGraph/worker/collectDependencies.js +215 -8
- package/src/ModuleGraph/worker/collectDependencies.js.flow +233 -13
- package/src/Server.js +2 -0
- package/src/Server.js.flow +9 -2
- package/src/cli.js +5 -0
- package/src/cli.js.flow +5 -0
- package/src/commands/build.js +4 -3
- package/src/commands/build.js.flow +3 -1
- package/src/commands/serve.js +3 -3
- package/src/commands/serve.js.flow +3 -1
- package/src/index.flow.js +392 -0
- package/src/index.flow.js.flow +480 -0
- package/src/index.js +8 -380
- package/src/index.js.flow +8 -466
- package/src/lib/CountingSet.js +116 -0
- package/src/lib/CountingSet.js.flow +126 -0
- package/src/lib/JsonReporter.js +0 -2
- package/src/lib/JsonReporter.js.flow +1 -1
- package/src/lib/getAppendScripts.js +10 -4
- package/src/lib/getAppendScripts.js.flow +6 -4
- package/src/lib/getPreludeCode.js +19 -1
- package/src/lib/getPreludeCode.js.flow +15 -0
- package/src/lib/getPrependedScripts.js +10 -2
- package/src/lib/getPrependedScripts.js.flow +11 -2
- package/src/lib/reporting.js +0 -2
- package/src/lib/reporting.js.flow +2 -1
- package/src/node-haste/DependencyGraph/ModuleResolution.js +15 -3
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +15 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js +78 -19
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +14 -9
- package/src/node-haste/DependencyGraph.js +2 -2
- package/src/node-haste/DependencyGraph.js.flow +4 -2
package/src/lib/JsonReporter.js
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
+
var _CountingSet = _interopRequireDefault(require("./CountingSet"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
const getInlineSourceMappingURL = require("../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL");
|
|
13
19
|
|
|
14
20
|
const sourceMapString = require("../DeltaBundler/Serializers/sourceMapString");
|
|
@@ -38,7 +44,7 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
38
44
|
path: "$$importBundleNames",
|
|
39
45
|
dependencies: new Map(),
|
|
40
46
|
getSource: () => Buffer.from(""),
|
|
41
|
-
inverseDependencies: new
|
|
47
|
+
inverseDependencies: new _CountingSet.default(),
|
|
42
48
|
output: [
|
|
43
49
|
{
|
|
44
50
|
type: "js/script/virtual",
|
|
@@ -64,7 +70,7 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
64
70
|
path: `require-${path}`,
|
|
65
71
|
dependencies: new Map(),
|
|
66
72
|
getSource: () => Buffer.from(""),
|
|
67
|
-
inverseDependencies: new
|
|
73
|
+
inverseDependencies: new _CountingSet.default(),
|
|
68
74
|
output: [
|
|
69
75
|
{
|
|
70
76
|
type: "js/script/virtual",
|
|
@@ -94,7 +100,7 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
94
100
|
path: "source-map",
|
|
95
101
|
dependencies: new Map(),
|
|
96
102
|
getSource: () => Buffer.from(""),
|
|
97
|
-
inverseDependencies: new
|
|
103
|
+
inverseDependencies: new _CountingSet.default(),
|
|
98
104
|
output: [
|
|
99
105
|
{
|
|
100
106
|
type: "js/script/virtual",
|
|
@@ -114,7 +120,7 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
114
120
|
path: "source-url",
|
|
115
121
|
dependencies: new Map(),
|
|
116
122
|
getSource: () => Buffer.from(""),
|
|
117
|
-
inverseDependencies: new
|
|
123
|
+
inverseDependencies: new _CountingSet.default(),
|
|
118
124
|
output: [
|
|
119
125
|
{
|
|
120
126
|
type: "js/script/virtual",
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import type {Module} from '../DeltaBundler';
|
|
14
14
|
|
|
15
|
+
import CountingSet from './CountingSet';
|
|
16
|
+
|
|
15
17
|
const getInlineSourceMappingURL = require('../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL');
|
|
16
18
|
const sourceMapString = require('../DeltaBundler/Serializers/sourceMapString');
|
|
17
19
|
const countLines = require('./countLines');
|
|
@@ -56,7 +58,7 @@ function getAppendScripts<T: number | string>(
|
|
|
56
58
|
path: '$$importBundleNames',
|
|
57
59
|
dependencies: new Map(),
|
|
58
60
|
getSource: (): Buffer => Buffer.from(''),
|
|
59
|
-
inverseDependencies: new
|
|
61
|
+
inverseDependencies: new CountingSet(),
|
|
60
62
|
output: [
|
|
61
63
|
{
|
|
62
64
|
type: 'js/script/virtual',
|
|
@@ -82,7 +84,7 @@ function getAppendScripts<T: number | string>(
|
|
|
82
84
|
path: `require-${path}`,
|
|
83
85
|
dependencies: new Map(),
|
|
84
86
|
getSource: (): Buffer => Buffer.from(''),
|
|
85
|
-
inverseDependencies: new
|
|
87
|
+
inverseDependencies: new CountingSet(),
|
|
86
88
|
output: [
|
|
87
89
|
{
|
|
88
90
|
type: 'js/script/virtual',
|
|
@@ -113,7 +115,7 @@ function getAppendScripts<T: number | string>(
|
|
|
113
115
|
path: 'source-map',
|
|
114
116
|
dependencies: new Map(),
|
|
115
117
|
getSource: (): Buffer => Buffer.from(''),
|
|
116
|
-
inverseDependencies: new
|
|
118
|
+
inverseDependencies: new CountingSet(),
|
|
117
119
|
output: [
|
|
118
120
|
{
|
|
119
121
|
type: 'js/script/virtual',
|
|
@@ -133,7 +135,7 @@ function getAppendScripts<T: number | string>(
|
|
|
133
135
|
path: 'source-url',
|
|
134
136
|
dependencies: new Map(),
|
|
135
137
|
getSource: (): Buffer => Buffer.from(''),
|
|
136
|
-
inverseDependencies: new
|
|
138
|
+
inverseDependencies: new CountingSet(),
|
|
137
139
|
output: [
|
|
138
140
|
{
|
|
139
141
|
type: 'js/script/virtual',
|
|
@@ -9,14 +9,32 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
function getPreludeCode({
|
|
12
|
+
function getPreludeCode({
|
|
13
|
+
extraVars,
|
|
14
|
+
isDev,
|
|
15
|
+
globalPrefix,
|
|
16
|
+
requireCycleIgnorePatterns,
|
|
17
|
+
}) {
|
|
13
18
|
const vars = [
|
|
19
|
+
// Ensure these variable names match the ones referenced in metro-runtime
|
|
20
|
+
// require.js
|
|
14
21
|
"__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()",
|
|
15
22
|
`__DEV__=${String(isDev)}`,
|
|
16
23
|
...formatExtraVars(extraVars),
|
|
17
24
|
"process=this.process||{}",
|
|
18
25
|
`__METRO_GLOBAL_PREFIX__='${globalPrefix}'`,
|
|
19
26
|
];
|
|
27
|
+
|
|
28
|
+
if (isDev) {
|
|
29
|
+
// Ensure these variable names match the ones referenced in metro-runtime
|
|
30
|
+
// require.js
|
|
31
|
+
vars.push(
|
|
32
|
+
`${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns
|
|
33
|
+
.map((regex) => regex.toString())
|
|
34
|
+
.join(",")}]`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
20
38
|
return `var ${vars.join(",")};${processEnv(
|
|
21
39
|
isDev ? "development" : "production"
|
|
22
40
|
)}`;
|
|
@@ -14,18 +14,33 @@ function getPreludeCode({
|
|
|
14
14
|
extraVars,
|
|
15
15
|
isDev,
|
|
16
16
|
globalPrefix,
|
|
17
|
+
requireCycleIgnorePatterns,
|
|
17
18
|
}: {
|
|
18
19
|
+extraVars?: {[string]: mixed, ...},
|
|
19
20
|
+isDev: boolean,
|
|
20
21
|
+globalPrefix: string,
|
|
22
|
+
+requireCycleIgnorePatterns: $ReadOnlyArray<RegExp>,
|
|
21
23
|
}): string {
|
|
22
24
|
const vars = [
|
|
25
|
+
// Ensure these variable names match the ones referenced in metro-runtime
|
|
26
|
+
// require.js
|
|
23
27
|
'__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()',
|
|
24
28
|
`__DEV__=${String(isDev)}`,
|
|
25
29
|
...formatExtraVars(extraVars),
|
|
26
30
|
'process=this.process||{}',
|
|
27
31
|
`__METRO_GLOBAL_PREFIX__='${globalPrefix}'`,
|
|
28
32
|
];
|
|
33
|
+
|
|
34
|
+
if (isDev) {
|
|
35
|
+
// Ensure these variable names match the ones referenced in metro-runtime
|
|
36
|
+
// require.js
|
|
37
|
+
vars.push(
|
|
38
|
+
`${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns
|
|
39
|
+
.map(regex => regex.toString())
|
|
40
|
+
.join(',')}]`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
return `var ${vars.join(',')};${processEnv(
|
|
30
45
|
isDev ? 'development' : 'production',
|
|
31
46
|
)}`;
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
+
var _CountingSet = _interopRequireDefault(require("./CountingSet"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
const countLines = require("./countLines");
|
|
13
19
|
|
|
14
20
|
const getPreludeCode = require("./getPreludeCode");
|
|
@@ -53,21 +59,23 @@ async function getPrependedScripts(config, options, bundler, deltaBundler) {
|
|
|
53
59
|
_getPrelude({
|
|
54
60
|
dev: options.dev,
|
|
55
61
|
globalPrefix: config.transformer.globalPrefix,
|
|
62
|
+
requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns,
|
|
56
63
|
}),
|
|
57
64
|
...dependencies.values(),
|
|
58
65
|
];
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
function _getPrelude({ dev, globalPrefix }) {
|
|
68
|
+
function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
62
69
|
const code = getPreludeCode({
|
|
63
70
|
isDev: dev,
|
|
64
71
|
globalPrefix,
|
|
72
|
+
requireCycleIgnorePatterns,
|
|
65
73
|
});
|
|
66
74
|
const name = "__prelude__";
|
|
67
75
|
return {
|
|
68
76
|
dependencies: new Map(),
|
|
69
77
|
getSource: () => Buffer.from(code),
|
|
70
|
-
inverseDependencies: new
|
|
78
|
+
inverseDependencies: new _CountingSet.default(),
|
|
71
79
|
path: name,
|
|
72
80
|
output: [
|
|
73
81
|
{
|
|
@@ -15,6 +15,8 @@ import type DeltaBundler, {Module} from '../DeltaBundler';
|
|
|
15
15
|
import type {TransformInputOptions} from '../DeltaBundler/types.flow';
|
|
16
16
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
17
17
|
|
|
18
|
+
import CountingSet from './CountingSet';
|
|
19
|
+
|
|
18
20
|
const countLines = require('./countLines');
|
|
19
21
|
const getPreludeCode = require('./getPreludeCode');
|
|
20
22
|
const transformHelpers = require('./transformHelpers');
|
|
@@ -69,6 +71,7 @@ async function getPrependedScripts(
|
|
|
69
71
|
_getPrelude({
|
|
70
72
|
dev: options.dev,
|
|
71
73
|
globalPrefix: config.transformer.globalPrefix,
|
|
74
|
+
requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns,
|
|
72
75
|
}),
|
|
73
76
|
...dependencies.values(),
|
|
74
77
|
];
|
|
@@ -77,18 +80,24 @@ async function getPrependedScripts(
|
|
|
77
80
|
function _getPrelude({
|
|
78
81
|
dev,
|
|
79
82
|
globalPrefix,
|
|
83
|
+
requireCycleIgnorePatterns,
|
|
80
84
|
}: {
|
|
81
85
|
dev: boolean,
|
|
82
86
|
globalPrefix: string,
|
|
87
|
+
requireCycleIgnorePatterns: $ReadOnlyArray<RegExp>,
|
|
83
88
|
...
|
|
84
89
|
}): Module<> {
|
|
85
|
-
const code = getPreludeCode({
|
|
90
|
+
const code = getPreludeCode({
|
|
91
|
+
isDev: dev,
|
|
92
|
+
globalPrefix,
|
|
93
|
+
requireCycleIgnorePatterns,
|
|
94
|
+
});
|
|
86
95
|
const name = '__prelude__';
|
|
87
96
|
|
|
88
97
|
return {
|
|
89
98
|
dependencies: new Map(),
|
|
90
99
|
getSource: (): Buffer => Buffer.from(code),
|
|
91
|
-
inverseDependencies: new
|
|
100
|
+
inverseDependencies: new CountingSet(),
|
|
92
101
|
path: name,
|
|
93
102
|
output: [
|
|
94
103
|
{
|
package/src/lib/reporting.js
CHANGED
|
@@ -144,7 +144,10 @@ class ModuleResolver {
|
|
|
144
144
|
` * ${Resolver.formatFileCandidates(
|
|
145
145
|
this._removeRoot(candidates.dir)
|
|
146
146
|
)}`,
|
|
147
|
-
].join("\n")
|
|
147
|
+
].join("\n"),
|
|
148
|
+
{
|
|
149
|
+
cause: error,
|
|
150
|
+
}
|
|
148
151
|
);
|
|
149
152
|
}
|
|
150
153
|
|
|
@@ -162,7 +165,10 @@ class ModuleResolver {
|
|
|
162
165
|
[
|
|
163
166
|
`${moduleName} could not be found within the project${hint || "."}`,
|
|
164
167
|
...displayDirPaths.map((dirPath) => ` ${dirPath}`),
|
|
165
|
-
].join("\n")
|
|
168
|
+
].join("\n"),
|
|
169
|
+
{
|
|
170
|
+
cause: error,
|
|
171
|
+
}
|
|
166
172
|
);
|
|
167
173
|
}
|
|
168
174
|
|
|
@@ -238,7 +244,11 @@ class UnableToResolveError extends Error {
|
|
|
238
244
|
* The name of the module that was required, no necessarily a path,
|
|
239
245
|
* ex. `./bar`, or `invariant`.
|
|
240
246
|
*/
|
|
241
|
-
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Original error that causes this error
|
|
250
|
+
*/
|
|
251
|
+
constructor(originModulePath, targetModuleName, message, options) {
|
|
242
252
|
super();
|
|
243
253
|
this.originModulePath = originModulePath;
|
|
244
254
|
this.targetModuleName = targetModuleName;
|
|
@@ -250,6 +260,8 @@ class UnableToResolveError extends Error {
|
|
|
250
260
|
originModulePath,
|
|
251
261
|
message
|
|
252
262
|
) + (codeFrameMessage ? "\n" + codeFrameMessage : "");
|
|
263
|
+
this.cause =
|
|
264
|
+
options === null || options === void 0 ? void 0 : options.cause;
|
|
253
265
|
}
|
|
254
266
|
|
|
255
267
|
buildCodeFrameMessage() {
|
|
@@ -201,6 +201,9 @@ class ModuleResolver<TModule: Moduleish, TPackage: Packageish> {
|
|
|
201
201
|
this._removeRoot(candidates.dir),
|
|
202
202
|
)}`,
|
|
203
203
|
].join('\n'),
|
|
204
|
+
{
|
|
205
|
+
cause: error,
|
|
206
|
+
},
|
|
204
207
|
);
|
|
205
208
|
}
|
|
206
209
|
if (error instanceof Resolver.FailedToResolveNameError) {
|
|
@@ -220,6 +223,9 @@ class ModuleResolver<TModule: Moduleish, TPackage: Packageish> {
|
|
|
220
223
|
`${moduleName} could not be found within the project${hint || '.'}`,
|
|
221
224
|
...displayDirPaths.map((dirPath: string) => ` ${dirPath}`),
|
|
222
225
|
].join('\n'),
|
|
226
|
+
{
|
|
227
|
+
cause: error,
|
|
228
|
+
},
|
|
223
229
|
);
|
|
224
230
|
}
|
|
225
231
|
throw error;
|
|
@@ -287,11 +293,18 @@ class UnableToResolveError extends Error {
|
|
|
287
293
|
* ex. `./bar`, or `invariant`.
|
|
288
294
|
*/
|
|
289
295
|
targetModuleName: string;
|
|
296
|
+
/**
|
|
297
|
+
* Original error that causes this error
|
|
298
|
+
*/
|
|
299
|
+
cause: ?Error;
|
|
290
300
|
|
|
291
301
|
constructor(
|
|
292
302
|
originModulePath: string,
|
|
293
303
|
targetModuleName: string,
|
|
294
304
|
message: string,
|
|
305
|
+
options?: $ReadOnly<{
|
|
306
|
+
cause?: Error,
|
|
307
|
+
}>,
|
|
295
308
|
) {
|
|
296
309
|
super();
|
|
297
310
|
this.originModulePath = originModulePath;
|
|
@@ -304,6 +317,8 @@ class UnableToResolveError extends Error {
|
|
|
304
317
|
originModulePath,
|
|
305
318
|
message,
|
|
306
319
|
) + (codeFrameMessage ? '\n' + codeFrameMessage : '');
|
|
320
|
+
|
|
321
|
+
this.cause = options?.cause;
|
|
307
322
|
}
|
|
308
323
|
|
|
309
324
|
buildCodeFrameMessage(): ?string {
|
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _metroFileMap =
|
|
3
|
+
var _metroFileMap = _interopRequireWildcard(require("metro-file-map"));
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
6
|
+
if (typeof WeakMap !== "function") return null;
|
|
7
|
+
var cacheBabelInterop = new WeakMap();
|
|
8
|
+
var cacheNodeInterop = new WeakMap();
|
|
9
|
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
|
10
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
11
|
+
})(nodeInterop);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
15
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
|
|
19
|
+
return { default: obj };
|
|
20
|
+
}
|
|
21
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
22
|
+
if (cache && cache.has(obj)) {
|
|
23
|
+
return cache.get(obj);
|
|
24
|
+
}
|
|
25
|
+
var newObj = {};
|
|
26
|
+
var hasPropertyDescriptor =
|
|
27
|
+
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
28
|
+
for (var key in obj) {
|
|
29
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
30
|
+
var desc = hasPropertyDescriptor
|
|
31
|
+
? Object.getOwnPropertyDescriptor(obj, key)
|
|
32
|
+
: null;
|
|
33
|
+
if (desc && (desc.get || desc.set)) {
|
|
34
|
+
Object.defineProperty(newObj, key, desc);
|
|
35
|
+
} else {
|
|
36
|
+
newObj[key] = obj[key];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
newObj.default = obj;
|
|
41
|
+
if (cache) {
|
|
42
|
+
cache.set(obj, newObj);
|
|
43
|
+
}
|
|
44
|
+
return newObj;
|
|
7
45
|
}
|
|
8
46
|
|
|
9
47
|
/**
|
|
@@ -19,8 +57,6 @@ const ci = require("ci-info");
|
|
|
19
57
|
|
|
20
58
|
const path = require("path");
|
|
21
59
|
|
|
22
|
-
const JEST_HASTE_MAP_CACHE_BREAKER = 5;
|
|
23
|
-
|
|
24
60
|
function getIgnorePattern(config) {
|
|
25
61
|
// For now we support both options
|
|
26
62
|
const { blockList, blacklistRE } = config.resolver;
|
|
@@ -45,7 +81,10 @@ function getIgnorePattern(config) {
|
|
|
45
81
|
}
|
|
46
82
|
|
|
47
83
|
function createHasteMap(config, options) {
|
|
48
|
-
var _config$
|
|
84
|
+
var _config$unstable_file,
|
|
85
|
+
_config$unstable_perf,
|
|
86
|
+
_config$unstable_perf2,
|
|
87
|
+
_options$throwOnModul;
|
|
49
88
|
|
|
50
89
|
const dependencyExtractor =
|
|
51
90
|
(options === null || options === void 0
|
|
@@ -55,28 +94,47 @@ function createHasteMap(config, options) {
|
|
|
55
94
|
: config.resolver.dependencyExtractor;
|
|
56
95
|
const computeDependencies = dependencyExtractor != null;
|
|
57
96
|
return _metroFileMap.default.create({
|
|
58
|
-
|
|
59
|
-
(_config$
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
97
|
+
cacheManagerFactory:
|
|
98
|
+
(_config$unstable_file =
|
|
99
|
+
config === null || config === void 0
|
|
100
|
+
? void 0
|
|
101
|
+
: config.unstable_fileMapCacheManagerFactory) !== null &&
|
|
102
|
+
_config$unstable_file !== void 0
|
|
103
|
+
? _config$unstable_file
|
|
104
|
+
: (buildParameters) => {
|
|
105
|
+
var _config$fileMapCacheD;
|
|
106
|
+
|
|
107
|
+
return new _metroFileMap.DiskCacheManager({
|
|
108
|
+
buildParameters,
|
|
109
|
+
cacheDirectory:
|
|
110
|
+
(_config$fileMapCacheD = config.fileMapCacheDirectory) !==
|
|
111
|
+
null && _config$fileMapCacheD !== void 0
|
|
112
|
+
? _config$fileMapCacheD
|
|
113
|
+
: config.hasteMapCacheDirectory,
|
|
114
|
+
cacheFilePrefix:
|
|
115
|
+
options === null || options === void 0
|
|
116
|
+
? void 0
|
|
117
|
+
: options.cacheFilePrefix,
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
perfLogger:
|
|
121
|
+
(_config$unstable_perf =
|
|
122
|
+
(_config$unstable_perf2 = config.unstable_perfLogger) === null ||
|
|
123
|
+
_config$unstable_perf2 === void 0
|
|
124
|
+
? void 0
|
|
125
|
+
: _config$unstable_perf2.subSpan("hasteMap")) !== null &&
|
|
126
|
+
_config$unstable_perf !== void 0
|
|
127
|
+
? _config$unstable_perf
|
|
128
|
+
: null,
|
|
63
129
|
computeDependencies,
|
|
64
130
|
computeSha1: true,
|
|
65
131
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
66
132
|
extensions: config.resolver.sourceExts.concat(config.resolver.assetExts),
|
|
67
133
|
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
68
134
|
hasteImplModulePath: config.resolver.hasteImplModulePath,
|
|
69
|
-
hasteMapModulePath: config.resolver.unstable_hasteMapModulePath,
|
|
70
135
|
ignorePattern: getIgnorePattern(config),
|
|
71
136
|
maxWorkers: config.maxWorkers,
|
|
72
137
|
mocksPattern: "",
|
|
73
|
-
name: `${
|
|
74
|
-
(_options$name =
|
|
75
|
-
options === null || options === void 0 ? void 0 : options.name) !==
|
|
76
|
-
null && _options$name !== void 0
|
|
77
|
-
? _options$name
|
|
78
|
-
: "metro"
|
|
79
|
-
}-${JEST_HASTE_MAP_CACHE_BREAKER}`,
|
|
80
138
|
platforms: config.resolver.platforms,
|
|
81
139
|
retainAllFiles: true,
|
|
82
140
|
resetCache: config.resetCache,
|
|
@@ -95,6 +153,7 @@ function createHasteMap(config, options) {
|
|
|
95
153
|
(options === null || options === void 0 ? void 0 : options.watch) == null
|
|
96
154
|
? !ci.isCI
|
|
97
155
|
: options.watch,
|
|
156
|
+
watchmanDeferStates: config.watcher.watchman.deferStates,
|
|
98
157
|
});
|
|
99
158
|
}
|
|
100
159
|
|
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
12
12
|
|
|
13
|
-
import MetroFileMap from 'metro-file-map';
|
|
13
|
+
import MetroFileMap, {DiskCacheManager} from 'metro-file-map';
|
|
14
14
|
|
|
15
15
|
const ci = require('ci-info');
|
|
16
16
|
const path = require('path');
|
|
17
17
|
|
|
18
|
-
const JEST_HASTE_MAP_CACHE_BREAKER = 5;
|
|
19
|
-
|
|
20
18
|
function getIgnorePattern(config: ConfigT): RegExp {
|
|
21
19
|
// For now we support both options
|
|
22
20
|
const {blockList, blacklistRE} = config.resolver;
|
|
@@ -27,7 +25,7 @@ function getIgnorePattern(config: ConfigT): RegExp {
|
|
|
27
25
|
return / ^/;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
const combine = regexes =>
|
|
28
|
+
const combine = (regexes: Array<RegExp>) =>
|
|
31
29
|
new RegExp(
|
|
32
30
|
regexes
|
|
33
31
|
.map(regex => '(' + regex.source.replace(/\//g, path.sep) + ')')
|
|
@@ -48,7 +46,7 @@ function createHasteMap(
|
|
|
48
46
|
extractDependencies?: boolean,
|
|
49
47
|
watch?: boolean,
|
|
50
48
|
throwOnModuleCollision?: boolean,
|
|
51
|
-
|
|
49
|
+
cacheFilePrefix?: string,
|
|
52
50
|
}>,
|
|
53
51
|
): MetroFileMap {
|
|
54
52
|
const dependencyExtractor =
|
|
@@ -58,19 +56,25 @@ function createHasteMap(
|
|
|
58
56
|
const computeDependencies = dependencyExtractor != null;
|
|
59
57
|
|
|
60
58
|
return MetroFileMap.create({
|
|
61
|
-
|
|
62
|
-
config
|
|
59
|
+
cacheManagerFactory:
|
|
60
|
+
config?.unstable_fileMapCacheManagerFactory ??
|
|
61
|
+
(buildParameters =>
|
|
62
|
+
new DiskCacheManager({
|
|
63
|
+
buildParameters,
|
|
64
|
+
cacheDirectory:
|
|
65
|
+
config.fileMapCacheDirectory ?? config.hasteMapCacheDirectory,
|
|
66
|
+
cacheFilePrefix: options?.cacheFilePrefix,
|
|
67
|
+
})),
|
|
68
|
+
perfLogger: config.unstable_perfLogger?.subSpan('hasteMap') ?? null,
|
|
63
69
|
computeDependencies,
|
|
64
70
|
computeSha1: true,
|
|
65
71
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
66
72
|
extensions: config.resolver.sourceExts.concat(config.resolver.assetExts),
|
|
67
73
|
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
68
74
|
hasteImplModulePath: config.resolver.hasteImplModulePath,
|
|
69
|
-
hasteMapModulePath: config.resolver.unstable_hasteMapModulePath,
|
|
70
75
|
ignorePattern: getIgnorePattern(config),
|
|
71
76
|
maxWorkers: config.maxWorkers,
|
|
72
77
|
mocksPattern: '',
|
|
73
|
-
name: `${options?.name ?? 'metro'}-${JEST_HASTE_MAP_CACHE_BREAKER}`,
|
|
74
78
|
platforms: config.resolver.platforms,
|
|
75
79
|
retainAllFiles: true,
|
|
76
80
|
resetCache: config.resetCache,
|
|
@@ -79,6 +83,7 @@ function createHasteMap(
|
|
|
79
83
|
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
|
|
80
84
|
useWatchman: config.resolver.useWatchman,
|
|
81
85
|
watch: options?.watch == null ? !ci.isCI : options.watch,
|
|
86
|
+
watchmanDeferStates: config.watcher.watchman.deferStates,
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -15,8 +15,6 @@ const createHasteMap = require("./DependencyGraph/createHasteMap");
|
|
|
15
15
|
|
|
16
16
|
const { ModuleResolver } = require("./DependencyGraph/ModuleResolution");
|
|
17
17
|
|
|
18
|
-
const Module = require("./Module");
|
|
19
|
-
|
|
20
18
|
const ModuleCache = require("./ModuleCache");
|
|
21
19
|
|
|
22
20
|
const { EventEmitter } = require("events");
|
|
@@ -117,6 +115,8 @@ class DependencyGraph extends EventEmitter {
|
|
|
117
115
|
|
|
118
116
|
return null;
|
|
119
117
|
}
|
|
118
|
+
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
119
|
+
* LTI update could not be added via codemod */
|
|
120
120
|
|
|
121
121
|
_onHasteChange({ eventsQueue, hasteFS, moduleMap }) {
|
|
122
122
|
this._hasteFS = hasteFS;
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
import type Package from './Package';
|
|
12
12
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
13
13
|
import type MetroFileMap, {HasteFS} from 'metro-file-map';
|
|
14
|
+
import type Module from './Module';
|
|
14
15
|
|
|
15
16
|
import {ModuleMap as MetroFileMapModuleMap} from 'metro-file-map';
|
|
16
17
|
|
|
17
18
|
const createHasteMap = require('./DependencyGraph/createHasteMap');
|
|
18
19
|
const {ModuleResolver} = require('./DependencyGraph/ModuleResolution');
|
|
19
|
-
const Module = require('./Module');
|
|
20
20
|
const ModuleCache = require('./ModuleCache');
|
|
21
21
|
const {EventEmitter} = require('events');
|
|
22
22
|
const fs = require('fs');
|
|
@@ -33,7 +33,7 @@ const {DuplicateHasteCandidatesError} = MetroFileMapModuleMap;
|
|
|
33
33
|
|
|
34
34
|
function getOrCreate<T>(
|
|
35
35
|
map: Map<string, Map<string, T>>,
|
|
36
|
-
field,
|
|
36
|
+
field: string,
|
|
37
37
|
): Map<string, T> {
|
|
38
38
|
let subMap = map.get(field);
|
|
39
39
|
if (!subMap) {
|
|
@@ -131,6 +131,8 @@ class DependencyGraph extends EventEmitter {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
135
|
+
* LTI update could not be added via codemod */
|
|
134
136
|
_onHasteChange({eventsQueue, hasteFS, moduleMap}) {
|
|
135
137
|
this._hasteFS = hasteFS;
|
|
136
138
|
this._resolutionCache = new Map();
|