metro 0.71.1 → 0.72.0
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 +22 -22
- package/src/Assets.js +3 -2
- package/src/Assets.js.flow +3 -2
- 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/WorkerFarm.js.flow +2 -2
- package/src/DeltaBundler/graphOperations.js +50 -47
- package/src/DeltaBundler/graphOperations.js.flow +46 -52
- package/src/DeltaBundler/types.flow.js +6 -0
- package/src/DeltaBundler/types.flow.js.flow +12 -3
- 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 +12 -3
- package/src/ModuleGraph/node-haste/node-haste.js.flow +34 -7
- package/src/ModuleGraph/output/util.js +1 -0
- package/src/ModuleGraph/output/util.js.flow +3 -2
- package/src/ModuleGraph/silent-console.js +5 -4
- package/src/ModuleGraph/silent-console.js.flow +8 -4
- package/src/ModuleGraph/worker/collectDependencies.js +229 -33
- package/src/ModuleGraph/worker/collectDependencies.js.flow +250 -48
- package/src/Server.js +4 -0
- package/src/Server.js.flow +11 -2
- package/src/cli-utils.js.flow +1 -1
- package/src/commands/build.js +1 -2
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +1 -1
- package/src/commands/serve.js +2 -1
- package/src/commands/serve.js.flow +7 -8
- package/src/index.flow.js +11 -8
- package/src/index.flow.js.flow +10 -7
- 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/createHasteMap.js +8 -1
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +9 -2
- package/src/node-haste/DependencyGraph.js +2 -2
- package/src/node-haste/DependencyGraph.js.flow +4 -2
- package/src/shared/output/bundle.flow.js +67 -0
- package/src/shared/output/bundle.flow.js.flow +89 -0
- package/src/shared/output/bundle.js +8 -55
- package/src/shared/output/bundle.js.flow +8 -75
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* @format
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A Set that only deletes a given item when the number of delete(item) calls
|
|
20
|
+
* matches the number of add(item) calls. Iteration and `size` are in terms of
|
|
21
|
+
* *unique* items.
|
|
22
|
+
*/
|
|
23
|
+
class CountingSet {
|
|
24
|
+
#map = new Map();
|
|
25
|
+
|
|
26
|
+
constructor(items) {
|
|
27
|
+
if (items) {
|
|
28
|
+
if (items instanceof CountingSet) {
|
|
29
|
+
this.#map = new Map(items.#map);
|
|
30
|
+
} else {
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
this.add(item);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
has(item) {
|
|
39
|
+
return this.#map.has(item);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
add(item) {
|
|
43
|
+
const newCount = this.count(item) + 1;
|
|
44
|
+
this.#map.set(item, newCount);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
delete(item) {
|
|
48
|
+
const newCount = this.count(item) - 1;
|
|
49
|
+
|
|
50
|
+
if (newCount <= 0) {
|
|
51
|
+
this.#map.delete(item);
|
|
52
|
+
} else {
|
|
53
|
+
this.#map.set(item, newCount);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
keys() {
|
|
58
|
+
return this.#map.keys();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
values() {
|
|
62
|
+
return this.#map.keys();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
*entries() {
|
|
66
|
+
for (const item of this) {
|
|
67
|
+
yield [item, item];
|
|
68
|
+
}
|
|
69
|
+
} // Iterate over unique entries
|
|
70
|
+
// $FlowIssue[unsupported-syntax]
|
|
71
|
+
|
|
72
|
+
[Symbol.iterator]() {
|
|
73
|
+
return this.values();
|
|
74
|
+
}
|
|
75
|
+
/*::
|
|
76
|
+
// For Flow's benefit
|
|
77
|
+
@@iterator(): Iterator<T> {
|
|
78
|
+
return this.values();
|
|
79
|
+
}
|
|
80
|
+
*/
|
|
81
|
+
// Number of unique entries
|
|
82
|
+
// $FlowIssue[unsafe-getters-setters]
|
|
83
|
+
|
|
84
|
+
get size() {
|
|
85
|
+
return this.#map.size;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
count(item) {
|
|
89
|
+
var _this$map$get;
|
|
90
|
+
|
|
91
|
+
return (_this$map$get = this.#map.get(item)) !== null &&
|
|
92
|
+
_this$map$get !== void 0
|
|
93
|
+
? _this$map$get
|
|
94
|
+
: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
clear() {
|
|
98
|
+
this.#map.clear();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
forEach(callbackFn, thisArg) {
|
|
102
|
+
for (const item of this) {
|
|
103
|
+
callbackFn.call(thisArg, item, item, this);
|
|
104
|
+
}
|
|
105
|
+
} // For Jest purposes. Ideally a custom serializer would be enough, but in
|
|
106
|
+
// practice there is hardcoded magic for Set in toEqual (etc) that we cannot
|
|
107
|
+
// extend to custom collection classes. Instead let's assume values are
|
|
108
|
+
// sortable ( = strings) and make this look like an array with some stable
|
|
109
|
+
// order.
|
|
110
|
+
|
|
111
|
+
toJSON() {
|
|
112
|
+
return [...this].sort();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
exports.default = CountingSet;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
12
|
+
has(item: T): boolean;
|
|
13
|
+
@@iterator(): Iterator<T>;
|
|
14
|
+
+size: number;
|
|
15
|
+
count(item: T): number;
|
|
16
|
+
forEach<ThisT>(
|
|
17
|
+
callbackFn: (
|
|
18
|
+
this: ThisT,
|
|
19
|
+
value: T,
|
|
20
|
+
key: T,
|
|
21
|
+
set: ReadOnlyCountingSet<T>,
|
|
22
|
+
) => mixed,
|
|
23
|
+
|
|
24
|
+
// NOTE: Should be optional, but Flow seems happy to infer undefined here
|
|
25
|
+
// which is what we want.
|
|
26
|
+
thisArg: ThisT,
|
|
27
|
+
): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A Set that only deletes a given item when the number of delete(item) calls
|
|
32
|
+
* matches the number of add(item) calls. Iteration and `size` are in terms of
|
|
33
|
+
* *unique* items.
|
|
34
|
+
*/
|
|
35
|
+
export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
36
|
+
#map: Map<T, number> = new Map();
|
|
37
|
+
|
|
38
|
+
constructor(items?: Iterable<T>) {
|
|
39
|
+
if (items) {
|
|
40
|
+
if (items instanceof CountingSet) {
|
|
41
|
+
this.#map = new Map(items.#map);
|
|
42
|
+
} else {
|
|
43
|
+
for (const item of items) {
|
|
44
|
+
this.add(item);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
has(item: T): boolean {
|
|
51
|
+
return this.#map.has(item);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
add(item: T): void {
|
|
55
|
+
const newCount = this.count(item) + 1;
|
|
56
|
+
this.#map.set(item, newCount);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
delete(item: T): void {
|
|
60
|
+
const newCount = this.count(item) - 1;
|
|
61
|
+
if (newCount <= 0) {
|
|
62
|
+
this.#map.delete(item);
|
|
63
|
+
} else {
|
|
64
|
+
this.#map.set(item, newCount);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
keys(): Iterator<T> {
|
|
69
|
+
return this.#map.keys();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
values(): Iterator<T> {
|
|
73
|
+
return this.#map.keys();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
*entries(): Iterator<[T, T]> {
|
|
77
|
+
for (const item of this) {
|
|
78
|
+
yield [item, item];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Iterate over unique entries
|
|
83
|
+
// $FlowIssue[unsupported-syntax]
|
|
84
|
+
[Symbol.iterator](): Iterator<T> {
|
|
85
|
+
return this.values();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/*::
|
|
89
|
+
// For Flow's benefit
|
|
90
|
+
@@iterator(): Iterator<T> {
|
|
91
|
+
return this.values();
|
|
92
|
+
}
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
// Number of unique entries
|
|
96
|
+
// $FlowIssue[unsafe-getters-setters]
|
|
97
|
+
get size(): number {
|
|
98
|
+
return this.#map.size;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
count(item: T): number {
|
|
102
|
+
return this.#map.get(item) ?? 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
clear(): void {
|
|
106
|
+
this.#map.clear();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
forEach<ThisT>(
|
|
110
|
+
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => mixed,
|
|
111
|
+
thisArg: ThisT,
|
|
112
|
+
): void {
|
|
113
|
+
for (const item of this) {
|
|
114
|
+
callbackFn.call(thisArg, item, item, this);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// For Jest purposes. Ideally a custom serializer would be enough, but in
|
|
119
|
+
// practice there is hardcoded magic for Set in toEqual (etc) that we cannot
|
|
120
|
+
// extend to custom collection classes. Instead let's assume values are
|
|
121
|
+
// sortable ( = strings) and make this look like an array with some stable
|
|
122
|
+
// order.
|
|
123
|
+
toJSON(): mixed {
|
|
124
|
+
return [...this].sort();
|
|
125
|
+
}
|
|
126
|
+
}
|
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
|
@@ -129,7 +129,13 @@ function createHasteMap(config, options) {
|
|
|
129
129
|
computeDependencies,
|
|
130
130
|
computeSha1: true,
|
|
131
131
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
132
|
-
extensions:
|
|
132
|
+
extensions: Array.from(
|
|
133
|
+
new Set([
|
|
134
|
+
...config.resolver.sourceExts,
|
|
135
|
+
...config.resolver.assetExts,
|
|
136
|
+
...config.watcher.additionalExts,
|
|
137
|
+
])
|
|
138
|
+
),
|
|
133
139
|
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
134
140
|
hasteImplModulePath: config.resolver.hasteImplModulePath,
|
|
135
141
|
ignorePattern: getIgnorePattern(config),
|
|
@@ -153,6 +159,7 @@ function createHasteMap(config, options) {
|
|
|
153
159
|
(options === null || options === void 0 ? void 0 : options.watch) == null
|
|
154
160
|
? !ci.isCI
|
|
155
161
|
: options.watch,
|
|
162
|
+
watchmanDeferStates: config.watcher.watchman.deferStates,
|
|
156
163
|
});
|
|
157
164
|
}
|
|
158
165
|
|
|
@@ -25,7 +25,7 @@ function getIgnorePattern(config: ConfigT): RegExp {
|
|
|
25
25
|
return / ^/;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const combine = regexes =>
|
|
28
|
+
const combine = (regexes: Array<RegExp>) =>
|
|
29
29
|
new RegExp(
|
|
30
30
|
regexes
|
|
31
31
|
.map(regex => '(' + regex.source.replace(/\//g, path.sep) + ')')
|
|
@@ -69,7 +69,13 @@ function createHasteMap(
|
|
|
69
69
|
computeDependencies,
|
|
70
70
|
computeSha1: true,
|
|
71
71
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
72
|
-
extensions:
|
|
72
|
+
extensions: Array.from(
|
|
73
|
+
new Set([
|
|
74
|
+
...config.resolver.sourceExts,
|
|
75
|
+
...config.resolver.assetExts,
|
|
76
|
+
...config.watcher.additionalExts,
|
|
77
|
+
]),
|
|
78
|
+
),
|
|
73
79
|
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
74
80
|
hasteImplModulePath: config.resolver.hasteImplModulePath,
|
|
75
81
|
ignorePattern: getIgnorePattern(config),
|
|
@@ -83,6 +89,7 @@ function createHasteMap(
|
|
|
83
89
|
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
|
|
84
90
|
useWatchman: config.resolver.useWatchman,
|
|
85
91
|
watch: options?.watch == null ? !ci.isCI : options.watch,
|
|
92
|
+
watchmanDeferStates: config.watcher.watchman.deferStates,
|
|
86
93
|
});
|
|
87
94
|
}
|
|
88
95
|
|
|
@@ -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();
|