metro 0.84.2 → 0.84.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 +15 -15
- package/src/Bundler/util.js.flow +3 -3
- package/src/DeltaBundler/DeltaCalculator.d.ts +1 -11
- package/src/DeltaBundler/DeltaCalculator.js +55 -46
- package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
- package/src/DeltaBundler/getTransformCacheKey.js +3 -1
- package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
- package/src/HmrServer.d.ts +15 -3
- package/src/HmrServer.js +7 -0
- package/src/HmrServer.js.flow +15 -5
- package/src/index.d.ts +22 -3
- package/src/index.flow.js.flow +21 -2
- package/src/lib/JsonReporter.js.flow +2 -2
- package/src/lib/getAppendScripts.js.flow +2 -2
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +9 -22
- package/src/node-haste/DependencyGraph/ModuleResolution.js +4 -22
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
- package/src/node-haste/DependencyGraph/createFileMap.js +1 -1
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -2
- package/src/node-haste/DependencyGraph.d.ts +2 -5
- package/src/node-haste/DependencyGraph.js +22 -11
- package/src/node-haste/DependencyGraph.js.flow +24 -13
- package/src/node-haste/PackageCache.d.ts +12 -16
- package/src/node-haste/PackageCache.js +65 -54
- package/src/node-haste/PackageCache.js.flow +103 -79
- package/src/node-haste/Package.d.ts +0 -28
- package/src/node-haste/Package.js +0 -28
- package/src/node-haste/Package.js.flow +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.3",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -34,24 +34,24 @@
|
|
|
34
34
|
"error-stack-parser": "^2.0.6",
|
|
35
35
|
"flow-enums-runtime": "^0.0.6",
|
|
36
36
|
"graceful-fs": "^4.2.4",
|
|
37
|
-
"hermes-parser": "0.
|
|
37
|
+
"hermes-parser": "0.35.0",
|
|
38
38
|
"image-size": "^1.0.2",
|
|
39
39
|
"invariant": "^2.2.4",
|
|
40
40
|
"jest-worker": "^29.7.0",
|
|
41
41
|
"jsc-safe-url": "^0.2.2",
|
|
42
42
|
"lodash.throttle": "^4.1.1",
|
|
43
|
-
"metro-babel-transformer": "0.84.
|
|
44
|
-
"metro-cache": "0.84.
|
|
45
|
-
"metro-cache-key": "0.84.
|
|
46
|
-
"metro-config": "0.84.
|
|
47
|
-
"metro-core": "0.84.
|
|
48
|
-
"metro-file-map": "0.84.
|
|
49
|
-
"metro-resolver": "0.84.
|
|
50
|
-
"metro-runtime": "0.84.
|
|
51
|
-
"metro-source-map": "0.84.
|
|
52
|
-
"metro-symbolicate": "0.84.
|
|
53
|
-
"metro-transform-plugins": "0.84.
|
|
54
|
-
"metro-transform-worker": "0.84.
|
|
43
|
+
"metro-babel-transformer": "0.84.3",
|
|
44
|
+
"metro-cache": "0.84.3",
|
|
45
|
+
"metro-cache-key": "0.84.3",
|
|
46
|
+
"metro-config": "0.84.3",
|
|
47
|
+
"metro-core": "0.84.3",
|
|
48
|
+
"metro-file-map": "0.84.3",
|
|
49
|
+
"metro-resolver": "0.84.3",
|
|
50
|
+
"metro-runtime": "0.84.3",
|
|
51
|
+
"metro-source-map": "0.84.3",
|
|
52
|
+
"metro-symbolicate": "0.84.3",
|
|
53
|
+
"metro-transform-plugins": "0.84.3",
|
|
54
|
+
"metro-transform-worker": "0.84.3",
|
|
55
55
|
"mime-types": "^3.0.1",
|
|
56
56
|
"nullthrows": "^1.1.1",
|
|
57
57
|
"serialize-error": "^2.1.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"dedent": "^0.7.0",
|
|
73
73
|
"jest-snapshot": "^29.7.0",
|
|
74
74
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
75
|
-
"metro-babel-register": "0.84.
|
|
75
|
+
"metro-babel-register": "0.84.3",
|
|
76
76
|
"metro-memory-fs": "*",
|
|
77
77
|
"mock-req": "^0.2.0",
|
|
78
78
|
"mock-res": "^0.6.0",
|
package/src/Bundler/util.js.flow
CHANGED
|
@@ -17,7 +17,7 @@ import * as babylon from '@babel/parser';
|
|
|
17
17
|
import template from '@babel/template';
|
|
18
18
|
import * as babelTypes from '@babel/types';
|
|
19
19
|
|
|
20
|
-
type SubTree<T
|
|
20
|
+
type SubTree<T extends ModuleTransportLike> = (
|
|
21
21
|
moduleTransport: T,
|
|
22
22
|
moduleTransportsByPath: Map<string, T>,
|
|
23
23
|
) => Iterable<number>;
|
|
@@ -66,7 +66,7 @@ function filterObject(
|
|
|
66
66
|
return copied;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export function createRamBundleGroups<T
|
|
69
|
+
export function createRamBundleGroups<T extends ModuleTransportLike>(
|
|
70
70
|
ramGroups: ReadonlyArray<string>,
|
|
71
71
|
groupableModules: ReadonlyArray<T>,
|
|
72
72
|
subtree: SubTree<T>,
|
|
@@ -123,7 +123,7 @@ export function createRamBundleGroups<T: ModuleTransportLike>(
|
|
|
123
123
|
return result;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
function* filter<A
|
|
126
|
+
function* filter<A extends number, B extends number>(
|
|
127
127
|
iterator: ArrayMap<A, B>,
|
|
128
128
|
predicate: ([A, Array<B>]) => boolean,
|
|
129
129
|
): Generator<[A, Array<B>], void, void> {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<d06b53dd09157df95aeb941035d4ebf0>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/DeltaBundler/DeltaCalculator.js
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type {DeltaResult, Options} from './types';
|
|
19
|
-
import type {RootPerfLogger} from 'metro-config';
|
|
20
19
|
import type {ChangeEvent} from 'metro-file-map';
|
|
21
20
|
|
|
22
21
|
import {Graph} from './Graph';
|
|
@@ -60,15 +59,6 @@ declare class DeltaCalculator<T> extends EventEmitter {
|
|
|
60
59
|
*/
|
|
61
60
|
getGraph(): Graph<T>;
|
|
62
61
|
_handleMultipleFileChanges: (changeEvent: ChangeEvent) => void;
|
|
63
|
-
/**
|
|
64
|
-
* Handles a single file change. To avoid doing any work before it's needed,
|
|
65
|
-
* the listener only stores the modified file, which will then be used later
|
|
66
|
-
* when the delta needs to be calculated.
|
|
67
|
-
*/
|
|
68
|
-
_handleFileChange: (
|
|
69
|
-
$$PARAM_0$$: ChangeEvent['eventsQueue'][number],
|
|
70
|
-
logger: null | undefined | RootPerfLogger,
|
|
71
|
-
) => unknown;
|
|
72
62
|
_getChangedDependencies(
|
|
73
63
|
modifiedFiles: Set<string>,
|
|
74
64
|
deletedFiles: Set<string>,
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _Graph = require("./Graph");
|
|
8
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
8
9
|
var _events = _interopRequireDefault(require("events"));
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
function _interopRequireDefault(e) {
|
|
11
12
|
return e && e.__esModule ? e : { default: e };
|
|
12
13
|
}
|
|
13
14
|
const debug = require("debug")("Metro:DeltaCalculator");
|
|
15
|
+
const changeEventIds = new WeakMap();
|
|
14
16
|
class DeltaCalculator extends _events.default {
|
|
15
17
|
_deletedFiles = new Set();
|
|
16
18
|
_modifiedFiles = new Set();
|
|
@@ -94,60 +96,67 @@ class DeltaCalculator extends _events.default {
|
|
|
94
96
|
getGraph() {
|
|
95
97
|
return this._graph;
|
|
96
98
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
_handleFileChange = ({ type, filePath, metadata }, logger) => {
|
|
103
|
-
debug("Handling %s: %s (type: %s)", type, filePath, metadata.type);
|
|
99
|
+
#shouldReset(canonicalPath, metadata) {
|
|
100
|
+
if (metadata.isSymlink) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
104
103
|
if (
|
|
105
|
-
|
|
106
|
-
(
|
|
107
|
-
|
|
104
|
+
this._options.unstable_enablePackageExports &&
|
|
105
|
+
(canonicalPath === "package.json" ||
|
|
106
|
+
canonicalPath.endsWith(_path.default.sep + "package.json"))
|
|
108
107
|
) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
_handleMultipleFileChanges = (changeEvent) => {
|
|
113
|
+
const { changes, logger, rootDir } = changeEvent;
|
|
114
|
+
for (const [canonicalPath, metadata] of changes.addedFiles) {
|
|
115
|
+
debug("Handling add: %s", canonicalPath);
|
|
116
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
117
|
+
this._requiresReset = true;
|
|
118
|
+
}
|
|
119
|
+
const absolutePath = _path.default.join(rootDir, canonicalPath);
|
|
120
|
+
if (this._deletedFiles.has(absolutePath)) {
|
|
121
|
+
this._deletedFiles.delete(absolutePath);
|
|
122
|
+
this._modifiedFiles.add(absolutePath);
|
|
123
|
+
} else {
|
|
124
|
+
this._addedFiles.add(absolutePath);
|
|
125
|
+
this._modifiedFiles.delete(absolutePath);
|
|
126
|
+
}
|
|
113
127
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
128
|
+
for (const [canonicalPath, metadata] of changes.modifiedFiles) {
|
|
129
|
+
debug("Handling change: %s", canonicalPath);
|
|
130
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
131
|
+
this._requiresReset = true;
|
|
132
|
+
}
|
|
133
|
+
const absolutePath = _path.default.join(rootDir, canonicalPath);
|
|
134
|
+
if (!this._addedFiles.has(absolutePath)) {
|
|
135
|
+
this._modifiedFiles.add(absolutePath);
|
|
136
|
+
}
|
|
137
|
+
this._deletedFiles.delete(absolutePath);
|
|
121
138
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
for (const [canonicalPath, metadata] of changes.removedFiles) {
|
|
140
|
+
debug("Handling delete: %s", canonicalPath);
|
|
141
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
142
|
+
this._requiresReset = true;
|
|
143
|
+
}
|
|
144
|
+
const absolutePath = _path.default.resolve(rootDir, canonicalPath);
|
|
145
|
+
if (this._addedFiles.has(absolutePath)) {
|
|
146
|
+
this._addedFiles.delete(absolutePath);
|
|
147
|
+
} else {
|
|
148
|
+
this._deletedFiles.add(absolutePath);
|
|
149
|
+
this._modifiedFiles.delete(absolutePath);
|
|
150
|
+
}
|
|
129
151
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this._addedFiles.delete(filePath);
|
|
135
|
-
break;
|
|
136
|
-
case "added":
|
|
137
|
-
this._addedFiles.add(filePath);
|
|
138
|
-
this._deletedFiles.delete(filePath);
|
|
139
|
-
this._modifiedFiles.delete(filePath);
|
|
140
|
-
break;
|
|
141
|
-
case "modified":
|
|
142
|
-
this._modifiedFiles.add(filePath);
|
|
143
|
-
this._deletedFiles.delete(filePath);
|
|
144
|
-
this._addedFiles.delete(filePath);
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
nextState;
|
|
152
|
+
let changeId = changeEventIds.get(changeEvent);
|
|
153
|
+
if (changeId == null) {
|
|
154
|
+
changeId = _crypto.default.randomUUID();
|
|
155
|
+
changeEventIds.set(changeEvent, changeId);
|
|
148
156
|
}
|
|
149
157
|
this.emit("change", {
|
|
150
158
|
logger,
|
|
159
|
+
changeId,
|
|
151
160
|
});
|
|
152
161
|
};
|
|
153
162
|
async _getChangedDependencies(modifiedFiles, deletedFiles, addedFiles) {
|
|
@@ -10,16 +10,24 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type {DeltaResult, Options} from './types';
|
|
13
|
-
import type {RootPerfLogger} from 'metro-config';
|
|
14
13
|
import type {ChangeEvent} from 'metro-file-map';
|
|
15
14
|
|
|
16
15
|
import {Graph} from './Graph';
|
|
16
|
+
import crypto from 'crypto';
|
|
17
17
|
import EventEmitter from 'events';
|
|
18
18
|
import path from 'path';
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line import/no-commonjs
|
|
21
21
|
const debug = require('debug')('Metro:DeltaCalculator');
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Assigns a unique, stable `changeId` to each `ChangeEvent` from the file
|
|
25
|
+
* watcher. Since all `DeltaCalculator` instances share the same
|
|
26
|
+
* `ChangeEvent` object reference per file system change, the `WeakMap`
|
|
27
|
+
* ensures each gets the same `changeId`.
|
|
28
|
+
*/
|
|
29
|
+
const changeEventIds: WeakMap<ChangeEvent, string> = new WeakMap();
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* This class is in charge of calculating the delta of changed modules that
|
|
25
33
|
* happen between calls. To do so, it subscribes to file changes, so it can
|
|
@@ -172,76 +180,79 @@ export default class DeltaCalculator<T> extends EventEmitter {
|
|
|
172
180
|
return this._graph;
|
|
173
181
|
}
|
|
174
182
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
#shouldReset(
|
|
184
|
+
canonicalPath: string,
|
|
185
|
+
metadata: {+isSymlink: boolean, ...},
|
|
186
|
+
): boolean {
|
|
187
|
+
if (metadata.isSymlink) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
180
190
|
|
|
181
|
-
/**
|
|
182
|
-
* Handles a single file change. To avoid doing any work before it's needed,
|
|
183
|
-
* the listener only stores the modified file, which will then be used later
|
|
184
|
-
* when the delta needs to be calculated.
|
|
185
|
-
*/
|
|
186
|
-
_handleFileChange = (
|
|
187
|
-
{type, filePath, metadata}: ChangeEvent['eventsQueue'][number],
|
|
188
|
-
logger: ?RootPerfLogger,
|
|
189
|
-
): unknown => {
|
|
190
|
-
debug('Handling %s: %s (type: %s)', type, filePath, metadata.type);
|
|
191
191
|
if (
|
|
192
|
-
|
|
193
|
-
(
|
|
194
|
-
|
|
192
|
+
this._options.unstable_enablePackageExports &&
|
|
193
|
+
(canonicalPath === 'package.json' ||
|
|
194
|
+
canonicalPath.endsWith(path.sep + 'package.json'))
|
|
195
195
|
) {
|
|
196
|
-
|
|
197
|
-
this.emit('change', {logger});
|
|
196
|
+
return true;
|
|
198
197
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
198
|
+
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
_handleMultipleFileChanges = (changeEvent: ChangeEvent) => {
|
|
203
|
+
const {changes, logger, rootDir} = changeEvent;
|
|
204
|
+
|
|
205
|
+
// Process added files: deleted+added = modified, otherwise added
|
|
206
|
+
for (const [canonicalPath, metadata] of changes.addedFiles) {
|
|
207
|
+
debug('Handling add: %s', canonicalPath);
|
|
208
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
209
|
+
this._requiresReset = true;
|
|
210
|
+
}
|
|
211
|
+
const absolutePath = path.join(rootDir, canonicalPath);
|
|
212
|
+
if (this._deletedFiles.has(absolutePath)) {
|
|
213
|
+
this._deletedFiles.delete(absolutePath);
|
|
214
|
+
this._modifiedFiles.add(absolutePath);
|
|
215
|
+
} else {
|
|
216
|
+
this._addedFiles.add(absolutePath);
|
|
217
|
+
this._modifiedFiles.delete(absolutePath);
|
|
218
|
+
}
|
|
206
219
|
}
|
|
207
220
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
// Process modified files: added+modified stays added, otherwise modified
|
|
222
|
+
for (const [canonicalPath, metadata] of changes.modifiedFiles) {
|
|
223
|
+
debug('Handling change: %s', canonicalPath);
|
|
224
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
225
|
+
this._requiresReset = true;
|
|
226
|
+
}
|
|
227
|
+
const absolutePath = path.join(rootDir, canonicalPath);
|
|
228
|
+
if (!this._addedFiles.has(absolutePath)) {
|
|
229
|
+
this._modifiedFiles.add(absolutePath);
|
|
230
|
+
}
|
|
231
|
+
this._deletedFiles.delete(absolutePath);
|
|
218
232
|
}
|
|
219
233
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
this.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this._deletedFiles.delete(filePath);
|
|
234
|
-
this._addedFiles.delete(filePath);
|
|
235
|
-
break;
|
|
236
|
-
default:
|
|
237
|
-
nextState as empty;
|
|
234
|
+
// Process removed files: added+deleted = no change, otherwise deleted
|
|
235
|
+
for (const [canonicalPath, metadata] of changes.removedFiles) {
|
|
236
|
+
debug('Handling delete: %s', canonicalPath);
|
|
237
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
238
|
+
this._requiresReset = true;
|
|
239
|
+
}
|
|
240
|
+
const absolutePath = path.resolve(rootDir, canonicalPath);
|
|
241
|
+
if (this._addedFiles.has(absolutePath)) {
|
|
242
|
+
this._addedFiles.delete(absolutePath);
|
|
243
|
+
} else {
|
|
244
|
+
this._deletedFiles.add(absolutePath);
|
|
245
|
+
this._modifiedFiles.delete(absolutePath);
|
|
246
|
+
}
|
|
238
247
|
}
|
|
239
248
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
249
|
+
let changeId = changeEventIds.get(changeEvent);
|
|
250
|
+
if (changeId == null) {
|
|
251
|
+
changeId = crypto.randomUUID();
|
|
252
|
+
changeEventIds.set(changeEvent, changeId);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
this.emit('change', {logger, changeId});
|
|
245
256
|
};
|
|
246
257
|
|
|
247
258
|
async _getChangedDependencies(
|
|
@@ -14,7 +14,9 @@ function getTransformCacheKey(opts) {
|
|
|
14
14
|
const { transformerPath, transformerConfig } = opts.transformerConfig;
|
|
15
15
|
const Transformer = require.call(null, transformerPath);
|
|
16
16
|
const transformerKey = Transformer.getCacheKey
|
|
17
|
-
? Transformer.getCacheKey(transformerConfig
|
|
17
|
+
? Transformer.getCacheKey(transformerConfig, {
|
|
18
|
+
projectRoot: opts.projectRoot,
|
|
19
|
+
})
|
|
18
20
|
: "";
|
|
19
21
|
return _crypto.default
|
|
20
22
|
.createHash("sha1")
|
|
@@ -19,7 +19,10 @@ import {getCacheKey} from 'metro-cache-key';
|
|
|
19
19
|
const VERSION = require('../../package.json').version;
|
|
20
20
|
|
|
21
21
|
type CacheKeyProvider = {
|
|
22
|
-
getCacheKey?:
|
|
22
|
+
getCacheKey?: (
|
|
23
|
+
config: JsTransformerConfig,
|
|
24
|
+
opts?: Readonly<{projectRoot: string}>,
|
|
25
|
+
) => string,
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export default function getTransformCacheKey(opts: {
|
|
@@ -32,7 +35,9 @@ export default function getTransformCacheKey(opts: {
|
|
|
32
35
|
// eslint-disable-next-line no-useless-call
|
|
33
36
|
const Transformer: CacheKeyProvider = require.call(null, transformerPath);
|
|
34
37
|
const transformerKey = Transformer.getCacheKey
|
|
35
|
-
? Transformer.getCacheKey(transformerConfig
|
|
38
|
+
? Transformer.getCacheKey(transformerConfig, {
|
|
39
|
+
projectRoot: opts.projectRoot,
|
|
40
|
+
})
|
|
36
41
|
: '';
|
|
37
42
|
|
|
38
43
|
return crypto
|
package/src/HmrServer.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
|
-
* @generated SignedSource<<
|
|
8
|
+
* @generated SignedSource<<ab4c245134631e14db114a9d49da79d1>>
|
|
9
9
|
*
|
|
10
10
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
11
|
* Original file: packages/metro/src/HmrServer.js
|
|
@@ -75,12 +75,24 @@ declare class HmrServer<TClient extends Client> {
|
|
|
75
75
|
_handleFileChange(
|
|
76
76
|
group: ClientGroup,
|
|
77
77
|
options: {isInitialUpdate: boolean},
|
|
78
|
-
changeEvent:
|
|
78
|
+
changeEvent:
|
|
79
|
+
| null
|
|
80
|
+
| undefined
|
|
81
|
+
| {
|
|
82
|
+
readonly logger: null | undefined | RootPerfLogger;
|
|
83
|
+
readonly changeId?: string;
|
|
84
|
+
},
|
|
79
85
|
): Promise<void>;
|
|
80
86
|
_prepareMessage(
|
|
81
87
|
group: ClientGroup,
|
|
82
88
|
options: {isInitialUpdate: boolean},
|
|
83
|
-
changeEvent:
|
|
89
|
+
changeEvent:
|
|
90
|
+
| null
|
|
91
|
+
| undefined
|
|
92
|
+
| {
|
|
93
|
+
readonly logger: null | undefined | RootPerfLogger;
|
|
94
|
+
readonly changeId?: string;
|
|
95
|
+
},
|
|
84
96
|
): Promise<HmrUpdateMessage | HmrErrorMessage>;
|
|
85
97
|
}
|
|
86
98
|
export default HmrServer;
|
package/src/HmrServer.js
CHANGED
|
@@ -214,6 +214,10 @@ class HmrServer {
|
|
|
214
214
|
case "log-opt-in":
|
|
215
215
|
client.optedIntoHMR = true;
|
|
216
216
|
break;
|
|
217
|
+
case "heartbeat":
|
|
218
|
+
debug("Heartbeat received");
|
|
219
|
+
sendFn(String(message));
|
|
220
|
+
break;
|
|
217
221
|
default:
|
|
218
222
|
break;
|
|
219
223
|
}
|
|
@@ -265,6 +269,9 @@ class HmrServer {
|
|
|
265
269
|
send(sendFns, message);
|
|
266
270
|
send(sendFns, {
|
|
267
271
|
type: "update-done",
|
|
272
|
+
body: {
|
|
273
|
+
changeId: changeEvent?.changeId,
|
|
274
|
+
},
|
|
268
275
|
});
|
|
269
276
|
log({
|
|
270
277
|
...createActionEndEntry(processingHmrChange),
|
package/src/HmrServer.js.flow
CHANGED
|
@@ -66,7 +66,7 @@ function send(sendFns: Array<(string) => void>, message: HmrMessage): void {
|
|
|
66
66
|
* getting connected, disconnected or having errors (through the
|
|
67
67
|
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
|
|
68
68
|
*/
|
|
69
|
-
export default class HmrServer<TClient
|
|
69
|
+
export default class HmrServer<TClient extends Client> {
|
|
70
70
|
_config: ConfigT;
|
|
71
71
|
_bundler: IncrementalBundler;
|
|
72
72
|
_createModuleId: (path: string) => number;
|
|
@@ -181,7 +181,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
181
181
|
this._clientGroups.set(id, clientGroup);
|
|
182
182
|
|
|
183
183
|
let latestChangeEvent: ?{
|
|
184
|
-
logger: ?RootPerfLogger,
|
|
184
|
+
+logger: ?RootPerfLogger,
|
|
185
|
+
+changeId: string,
|
|
185
186
|
} = null;
|
|
186
187
|
|
|
187
188
|
const debounceCallHandleFileChange = debounceAsyncQueue(async () => {
|
|
@@ -240,6 +241,10 @@ export default class HmrServer<TClient: Client> {
|
|
|
240
241
|
case 'log-opt-in':
|
|
241
242
|
client.optedIntoHMR = true;
|
|
242
243
|
break;
|
|
244
|
+
case 'heartbeat':
|
|
245
|
+
debug('Heartbeat received');
|
|
246
|
+
sendFn(String(message));
|
|
247
|
+
break;
|
|
243
248
|
default:
|
|
244
249
|
break;
|
|
245
250
|
}
|
|
@@ -273,7 +278,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
273
278
|
group: ClientGroup,
|
|
274
279
|
options: {isInitialUpdate: boolean},
|
|
275
280
|
changeEvent: ?{
|
|
276
|
-
logger: ?RootPerfLogger,
|
|
281
|
+
+logger: ?RootPerfLogger,
|
|
282
|
+
+changeId?: string,
|
|
277
283
|
},
|
|
278
284
|
): Promise<void> {
|
|
279
285
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -308,7 +314,10 @@ export default class HmrServer<TClient: Client> {
|
|
|
308
314
|
|
|
309
315
|
const message = await this._prepareMessage(group, options, changeEvent);
|
|
310
316
|
send(sendFns, message);
|
|
311
|
-
send(sendFns, {
|
|
317
|
+
send(sendFns, {
|
|
318
|
+
type: 'update-done',
|
|
319
|
+
body: {changeId: changeEvent?.changeId},
|
|
320
|
+
});
|
|
312
321
|
|
|
313
322
|
log({
|
|
314
323
|
...createActionEndEntry(processingHmrChange),
|
|
@@ -328,7 +337,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
328
337
|
group: ClientGroup,
|
|
329
338
|
options: {isInitialUpdate: boolean},
|
|
330
339
|
changeEvent: ?{
|
|
331
|
-
logger: ?RootPerfLogger,
|
|
340
|
+
+logger: ?RootPerfLogger,
|
|
341
|
+
+changeId?: string,
|
|
332
342
|
},
|
|
333
343
|
): Promise<HmrUpdateMessage | HmrErrorMessage> {
|
|
334
344
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
package/src/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<3c6460427c6760887187d6b16151c609>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/index.flow.js
|
|
@@ -125,9 +125,28 @@ type DependenciesCommandOptions = Readonly<{
|
|
|
125
125
|
}> | null;
|
|
126
126
|
export {Terminal, JsonReporter, TerminalReporter};
|
|
127
127
|
export type {AssetData} from './Assets';
|
|
128
|
-
export type {
|
|
128
|
+
export type {
|
|
129
|
+
AsyncDependencyType,
|
|
130
|
+
DeltaResult,
|
|
131
|
+
Dependency,
|
|
132
|
+
MixedOutput,
|
|
133
|
+
Module,
|
|
134
|
+
ReadOnlyDependencies,
|
|
135
|
+
ReadOnlyGraph,
|
|
136
|
+
SerializerOptions,
|
|
137
|
+
TransformInputOptions,
|
|
138
|
+
TransformResult,
|
|
139
|
+
TransformResultDependency,
|
|
140
|
+
} from './DeltaBundler/types';
|
|
141
|
+
export type {default as DependencyGraph} from './node-haste/DependencyGraph';
|
|
142
|
+
export type {BundleDetails, Reporter, ReportableEvent} from './lib/reporting';
|
|
129
143
|
export type {TerminalReportableEvent} from './lib/TerminalReporter';
|
|
130
|
-
export type {
|
|
144
|
+
export type {
|
|
145
|
+
ContextMode,
|
|
146
|
+
RequireContextParams,
|
|
147
|
+
} from './ModuleGraph/worker/collectDependencies';
|
|
148
|
+
export type {ServerOptions} from './Server';
|
|
149
|
+
export type {MetroConfig, MetroServer};
|
|
131
150
|
export declare function runMetro(
|
|
132
151
|
config: InputConfigT,
|
|
133
152
|
options?: RunMetroOptions,
|
package/src/index.flow.js.flow
CHANGED
|
@@ -156,9 +156,28 @@ type DependenciesCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
|
156
156
|
export {Terminal, JsonReporter, TerminalReporter};
|
|
157
157
|
|
|
158
158
|
export type {AssetData} from './Assets';
|
|
159
|
-
export type {
|
|
159
|
+
export type {
|
|
160
|
+
AsyncDependencyType,
|
|
161
|
+
DeltaResult,
|
|
162
|
+
Dependency,
|
|
163
|
+
MixedOutput,
|
|
164
|
+
Module,
|
|
165
|
+
ReadOnlyDependencies,
|
|
166
|
+
ReadOnlyGraph,
|
|
167
|
+
SerializerOptions,
|
|
168
|
+
TransformInputOptions,
|
|
169
|
+
TransformResult,
|
|
170
|
+
TransformResultDependency,
|
|
171
|
+
} from './DeltaBundler/types';
|
|
172
|
+
export type {default as DependencyGraph} from './node-haste/DependencyGraph';
|
|
173
|
+
export type {BundleDetails, Reporter, ReportableEvent} from './lib/reporting';
|
|
160
174
|
export type {TerminalReportableEvent} from './lib/TerminalReporter';
|
|
161
|
-
export type {
|
|
175
|
+
export type {
|
|
176
|
+
ContextMode,
|
|
177
|
+
RequireContextParams,
|
|
178
|
+
} from './ModuleGraph/worker/collectDependencies';
|
|
179
|
+
export type {ServerOptions} from './Server';
|
|
180
|
+
export type {MetroConfig, MetroServer};
|
|
162
181
|
|
|
163
182
|
async function getConfig(config: InputConfigT): Promise<ConfigT> {
|
|
164
183
|
const defaultConfig = await getDefaultConfig(config.projectRoot);
|
|
@@ -19,7 +19,7 @@ export type SerializedError = {
|
|
|
19
19
|
...
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type SerializedEvent<TEvent
|
|
22
|
+
export type SerializedEvent<TEvent extends {+[string]: unknown, ...}> =
|
|
23
23
|
TEvent extends {
|
|
24
24
|
error: Error,
|
|
25
25
|
...
|
|
@@ -31,7 +31,7 @@ export type SerializedEvent<TEvent: {+[string]: unknown, ...}> =
|
|
|
31
31
|
}
|
|
32
32
|
: TEvent;
|
|
33
33
|
|
|
34
|
-
export default class JsonReporter<TEvent
|
|
34
|
+
export default class JsonReporter<TEvent extends {+[string]: unknown, ...}> {
|
|
35
35
|
_stream: Writable;
|
|
36
36
|
|
|
37
37
|
constructor(stream: Writable) {
|