metro 0.84.3 → 0.85.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 +17 -18
- package/src/Assets.js +23 -14
- package/src/Assets.js.flow +51 -38
- package/src/Bundler.d.ts +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +1 -16
- package/src/DeltaBundler/DeltaCalculator.js.flow +1 -1
- package/src/DeltaBundler/Graph.d.ts +1 -102
- package/src/DeltaBundler/Graph.js.flow +7 -7
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAssets.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +5 -5
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +3 -3
- package/src/DeltaBundler/Transformer.d.ts +2 -10
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +2 -47
- package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -3
- package/src/DeltaBundler/types.js.flow +10 -10
- package/src/DeltaBundler.d.ts +1 -5
- package/src/HmrServer.d.ts +2 -45
- package/src/HmrServer.js.flow +10 -10
- package/src/IncrementalBundler.d.ts +1 -9
- package/src/IncrementalBundler.js.flow +9 -6
- package/src/ModuleGraph/worker/collectDependencies.d.ts +1 -2
- package/src/ModuleGraph/worker/collectDependencies.js +52 -0
- package/src/ModuleGraph/worker/collectDependencies.js.flow +67 -0
- package/src/Server/symbolicate.js.flow +13 -13
- package/src/Server.d.ts +3 -176
- package/src/Server.js +42 -5
- package/src/Server.js.flow +70 -28
- package/src/index.flow.js +2 -2
- package/src/index.flow.js.flow +2 -2
- package/src/lib/BatchProcessor.d.ts +1 -21
- package/src/lib/CountingSet.js.flow +1 -1
- package/src/lib/JsonReporter.d.ts +1 -2
- package/src/lib/JsonReporter.js.flow +4 -2
- package/src/lib/RamBundleParser.d.ts +1 -6
- package/src/lib/TerminalReporter.d.ts +2 -78
- package/src/lib/TerminalReporter.js +39 -41
- package/src/lib/TerminalReporter.js.flow +52 -33
- package/src/lib/bundleToString.js.flow +2 -2
- package/src/lib/createWebsocketServer.js.flow +4 -4
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getPreludeCode.js.flow +5 -5
- package/src/lib/logToConsole.js +8 -7
- package/src/lib/logToConsole.js.flow +7 -7
- package/src/lib/reporting.js +16 -7
- package/src/lib/reporting.js.flow +16 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +1 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +1 -1
- package/src/node-haste/DependencyGraph/createFileMap.js +0 -2
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +0 -2
- package/src/node-haste/DependencyGraph.d.ts +1 -30
- package/src/node-haste/DependencyGraph.js.flow +2 -2
- package/src/shared/output/RamBundle/util.js.flow +4 -2
- package/src/shared/types.js.flow +31 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
14
|
+
"url": "git+https://github.com/react/metro.git",
|
|
15
15
|
"directory": "packages/metro"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
@@ -27,31 +27,30 @@
|
|
|
27
27
|
"@babel/traverse": "^7.29.0",
|
|
28
28
|
"@babel/types": "^7.29.0",
|
|
29
29
|
"accepts": "^2.0.0",
|
|
30
|
-
"chalk": "^4.0.0",
|
|
31
30
|
"ci-info": "^2.0.0",
|
|
32
31
|
"connect": "^3.6.5",
|
|
33
32
|
"debug": "^4.4.0",
|
|
34
33
|
"error-stack-parser": "^2.0.6",
|
|
35
34
|
"flow-enums-runtime": "^0.0.6",
|
|
36
35
|
"graceful-fs": "^4.2.4",
|
|
37
|
-
"hermes-parser": "0.
|
|
36
|
+
"hermes-parser": "0.36.1",
|
|
38
37
|
"image-size": "^1.0.2",
|
|
39
38
|
"invariant": "^2.2.4",
|
|
40
39
|
"jest-worker": "^29.7.0",
|
|
41
40
|
"jsc-safe-url": "^0.2.2",
|
|
42
41
|
"lodash.throttle": "^4.1.1",
|
|
43
|
-
"metro-babel-transformer": "0.
|
|
44
|
-
"metro-cache": "0.
|
|
45
|
-
"metro-cache-key": "0.
|
|
46
|
-
"metro-config": "0.
|
|
47
|
-
"metro-core": "0.
|
|
48
|
-
"metro-file-map": "0.
|
|
49
|
-
"metro-resolver": "0.
|
|
50
|
-
"metro-runtime": "0.
|
|
51
|
-
"metro-source-map": "0.
|
|
52
|
-
"metro-symbolicate": "0.
|
|
53
|
-
"metro-transform-plugins": "0.
|
|
54
|
-
"metro-transform-worker": "0.
|
|
42
|
+
"metro-babel-transformer": "0.85.0",
|
|
43
|
+
"metro-cache": "0.85.0",
|
|
44
|
+
"metro-cache-key": "0.85.0",
|
|
45
|
+
"metro-config": "0.85.0",
|
|
46
|
+
"metro-core": "0.85.0",
|
|
47
|
+
"metro-file-map": "0.85.0",
|
|
48
|
+
"metro-resolver": "0.85.0",
|
|
49
|
+
"metro-runtime": "0.85.0",
|
|
50
|
+
"metro-source-map": "0.85.0",
|
|
51
|
+
"metro-symbolicate": "0.85.0",
|
|
52
|
+
"metro-transform-plugins": "0.85.0",
|
|
53
|
+
"metro-transform-worker": "0.85.0",
|
|
55
54
|
"mime-types": "^3.0.1",
|
|
56
55
|
"nullthrows": "^1.1.1",
|
|
57
56
|
"serialize-error": "^2.1.0",
|
|
@@ -72,7 +71,7 @@
|
|
|
72
71
|
"dedent": "^0.7.0",
|
|
73
72
|
"jest-snapshot": "^29.7.0",
|
|
74
73
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
75
|
-
"metro-babel-register": "0.
|
|
74
|
+
"metro-babel-register": "0.85.0",
|
|
76
75
|
"metro-memory-fs": "*",
|
|
77
76
|
"mock-req": "^0.2.0",
|
|
78
77
|
"mock-res": "^0.6.0",
|
|
@@ -81,6 +80,6 @@
|
|
|
81
80
|
},
|
|
82
81
|
"license": "MIT",
|
|
83
82
|
"engines": {
|
|
84
|
-
"node": "^
|
|
83
|
+
"node": "^22.13.0 || ^24.3.0 || >= 26.0.0"
|
|
85
84
|
}
|
|
86
85
|
}
|
package/src/Assets.js
CHANGED
|
@@ -195,7 +195,9 @@ async function applyAssetDataPlugins(assetDataPlugins, assetData) {
|
|
|
195
195
|
return assetData;
|
|
196
196
|
}
|
|
197
197
|
const [currentAssetPlugin, ...remainingAssetPlugins] = assetDataPlugins;
|
|
198
|
-
const
|
|
198
|
+
const mod = require(currentAssetPlugin);
|
|
199
|
+
const assetPluginFunction =
|
|
200
|
+
mod.__esModule === true && "default" in mod ? mod.default : mod;
|
|
199
201
|
const resultAssetData = await assetPluginFunction(assetData);
|
|
200
202
|
return await applyAssetDataPlugins(remainingAssetPlugins, resultAssetData);
|
|
201
203
|
}
|
|
@@ -221,26 +223,33 @@ async function getAsset(
|
|
|
221
223
|
`'${relativePath}' cannot be loaded as its extension is not registered in assetExts`,
|
|
222
224
|
);
|
|
223
225
|
}
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])) {
|
|
232
|
-
throw new Error(
|
|
233
|
-
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
|
|
234
|
-
);
|
|
235
|
-
}
|
|
226
|
+
if (
|
|
227
|
+
fileExistsInFileMap == null &&
|
|
228
|
+
!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])
|
|
229
|
+
) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
|
|
232
|
+
);
|
|
236
233
|
}
|
|
237
234
|
const record = await getAbsoluteAssetRecord(absolutePath, platform ?? null);
|
|
238
235
|
for (let i = 0; i < record.scales.length; i++) {
|
|
239
236
|
if (record.scales[i] >= assetData.resolution) {
|
|
237
|
+
if (
|
|
238
|
+
fileExistsInFileMap != null &&
|
|
239
|
+
!fileExistsInFileMap(record.files[i])
|
|
240
|
+
) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
240
243
|
return _fs.default.promises.readFile(record.files[i]);
|
|
241
244
|
}
|
|
242
245
|
}
|
|
243
|
-
|
|
246
|
+
const lastFile = record.files[record.files.length - 1];
|
|
247
|
+
if (fileExistsInFileMap != null && !fileExistsInFileMap(lastFile)) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
`'${relativePath}' could not be found, because it is not within the projectRoot or watchFolders, or it is blocked via the resolver.blockList config`,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
return _fs.default.promises.readFile(lastFile);
|
|
244
253
|
}
|
|
245
254
|
function pathBelongsToRoots(pathToCheck, roots) {
|
|
246
255
|
for (const rootFolder of roots) {
|
package/src/Assets.js.flow
CHANGED
|
@@ -20,34 +20,34 @@ import getImageSize from 'image-size';
|
|
|
20
20
|
import path from 'path';
|
|
21
21
|
|
|
22
22
|
export type AssetInfo = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
readonly files: Array<string>,
|
|
24
|
+
readonly hash: string,
|
|
25
|
+
readonly name: string,
|
|
26
|
+
readonly scales: Array<number>,
|
|
27
|
+
readonly type: string,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export type AssetDataWithoutFiles = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
readonly __packager_asset: boolean,
|
|
32
|
+
readonly fileSystemLocation: string,
|
|
33
|
+
readonly hash: string,
|
|
34
|
+
readonly height: ?number,
|
|
35
|
+
readonly httpServerLocation: string,
|
|
36
|
+
readonly name: string,
|
|
37
|
+
readonly scales: Array<number>,
|
|
38
|
+
readonly type: string,
|
|
39
|
+
readonly width: ?number,
|
|
40
40
|
...
|
|
41
41
|
};
|
|
42
42
|
export type AssetDataFiltered = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
readonly __packager_asset: boolean,
|
|
44
|
+
readonly hash: string,
|
|
45
|
+
readonly height: ?number,
|
|
46
|
+
readonly httpServerLocation: string,
|
|
47
|
+
readonly name: string,
|
|
48
|
+
readonly scales: Array<number>,
|
|
49
|
+
readonly type: string,
|
|
50
|
+
readonly width: ?number,
|
|
51
51
|
...
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -74,7 +74,7 @@ export function getAssetSize(
|
|
|
74
74
|
type: string,
|
|
75
75
|
content: Buffer,
|
|
76
76
|
filePath: string,
|
|
77
|
-
): ?{
|
|
77
|
+
): ?{readonly width: number, readonly height: number} {
|
|
78
78
|
if (!isAssetTypeAnImage(type)) {
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
@@ -85,7 +85,10 @@ export function getAssetSize(
|
|
|
85
85
|
return {width, height};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export type AssetData = AssetDataWithoutFiles & {
|
|
88
|
+
export type AssetData = AssetDataWithoutFiles & {
|
|
89
|
+
readonly files: Array<string>,
|
|
90
|
+
...
|
|
91
|
+
};
|
|
89
92
|
|
|
90
93
|
export type AssetDataPlugin = (
|
|
91
94
|
assetData: AssetData,
|
|
@@ -249,7 +252,10 @@ async function applyAssetDataPlugins(
|
|
|
249
252
|
|
|
250
253
|
const [currentAssetPlugin, ...remainingAssetPlugins] = assetDataPlugins;
|
|
251
254
|
// $FlowFixMe[unsupported-syntax]: impossible to type a dynamic require.
|
|
252
|
-
const
|
|
255
|
+
const mod = require(currentAssetPlugin);
|
|
256
|
+
const assetPluginFunction: AssetDataPlugin =
|
|
257
|
+
mod.__esModule === true && 'default' in mod ? mod.default : mod;
|
|
258
|
+
|
|
253
259
|
const resultAssetData = await assetPluginFunction(assetData);
|
|
254
260
|
return await applyAssetDataPlugins(remainingAssetPlugins, resultAssetData);
|
|
255
261
|
}
|
|
@@ -299,29 +305,36 @@ export async function getAsset(
|
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
// NOTE: If fileExistsInFileMap is not provided, we fall back to pathBelongsToRoots for backward compatibility, as getAsset is part of the public API.
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])) {
|
|
310
|
-
throw new Error(
|
|
311
|
-
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
|
|
312
|
-
);
|
|
313
|
-
}
|
|
308
|
+
if (
|
|
309
|
+
fileExistsInFileMap == null &&
|
|
310
|
+
!pathBelongsToRoots(absolutePath, [projectRoot, ...watchFolders])
|
|
311
|
+
) {
|
|
312
|
+
throw new Error(
|
|
313
|
+
`'${relativePath}' could not be found, because it cannot be found in the project root or any watch folder`,
|
|
314
|
+
);
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
const record = await getAbsoluteAssetRecord(absolutePath, platform ?? null);
|
|
317
318
|
|
|
318
319
|
for (let i = 0; i < record.scales.length; i++) {
|
|
319
320
|
if (record.scales[i] >= assetData.resolution) {
|
|
321
|
+
if (
|
|
322
|
+
fileExistsInFileMap != null &&
|
|
323
|
+
!fileExistsInFileMap(record.files[i])
|
|
324
|
+
) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
320
327
|
return fs.promises.readFile(record.files[i]);
|
|
321
328
|
}
|
|
322
329
|
}
|
|
323
330
|
|
|
324
|
-
|
|
331
|
+
const lastFile = record.files[record.files.length - 1];
|
|
332
|
+
if (fileExistsInFileMap != null && !fileExistsInFileMap(lastFile)) {
|
|
333
|
+
throw new Error(
|
|
334
|
+
`'${relativePath}' could not be found, because it is not within the projectRoot or watchFolders, or it is blocked via the resolver.blockList config`,
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
return fs.promises.readFile(lastFile);
|
|
325
338
|
}
|
|
326
339
|
|
|
327
340
|
function pathBelongsToRoots(
|
package/src/Bundler.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<fe2c52b16f1a3036429ec004623d3603>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/Bundler.js
|
|
@@ -20,7 +20,6 @@ import type {TransformOptions} from './DeltaBundler/Worker';
|
|
|
20
20
|
import type EventEmitter from 'events';
|
|
21
21
|
import type {ConfigT} from 'metro-config';
|
|
22
22
|
|
|
23
|
-
import Transformer from './DeltaBundler/Transformer';
|
|
24
23
|
import DependencyGraph from './node-haste/DependencyGraph';
|
|
25
24
|
|
|
26
25
|
export type BundlerOptions = Readonly<{
|
|
@@ -28,9 +27,6 @@ export type BundlerOptions = Readonly<{
|
|
|
28
27
|
watch?: boolean;
|
|
29
28
|
}>;
|
|
30
29
|
declare class Bundler {
|
|
31
|
-
_depGraph: DependencyGraph;
|
|
32
|
-
_initializedPromise: Promise<void>;
|
|
33
|
-
_transformer: Transformer;
|
|
34
30
|
constructor(config: ConfigT, options?: BundlerOptions);
|
|
35
31
|
getWatcher(): EventEmitter;
|
|
36
32
|
end(): Promise<void>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<1fbdc1ddc3526c8742b8c22d02311d38>>
|
|
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 {ChangeEvent} from 'metro-file-map';
|
|
20
19
|
|
|
21
20
|
import {Graph} from './Graph';
|
|
22
21
|
import EventEmitter from 'events';
|
|
@@ -27,14 +26,6 @@ import EventEmitter from 'events';
|
|
|
27
26
|
* traverse the whole dependency tree for trivial small changes.
|
|
28
27
|
*/
|
|
29
28
|
declare class DeltaCalculator<T> extends EventEmitter {
|
|
30
|
-
_changeEventSource: EventEmitter;
|
|
31
|
-
_options: Options<T>;
|
|
32
|
-
_currentBuildPromise: null | undefined | Promise<DeltaResult<T>>;
|
|
33
|
-
_deletedFiles: Set<string>;
|
|
34
|
-
_modifiedFiles: Set<string>;
|
|
35
|
-
_addedFiles: Set<string>;
|
|
36
|
-
_requiresReset: boolean;
|
|
37
|
-
_graph: Graph<T>;
|
|
38
29
|
constructor(
|
|
39
30
|
entryPoints: ReadonlySet<string>,
|
|
40
31
|
changeEventSource: EventEmitter,
|
|
@@ -58,11 +49,5 @@ declare class DeltaCalculator<T> extends EventEmitter {
|
|
|
58
49
|
* plus some metadata.
|
|
59
50
|
*/
|
|
60
51
|
getGraph(): Graph<T>;
|
|
61
|
-
_handleMultipleFileChanges: (changeEvent: ChangeEvent) => void;
|
|
62
|
-
_getChangedDependencies(
|
|
63
|
-
modifiedFiles: Set<string>,
|
|
64
|
-
deletedFiles: Set<string>,
|
|
65
|
-
addedFiles: Set<string>,
|
|
66
|
-
): Promise<DeltaResult<T>>;
|
|
67
52
|
}
|
|
68
53
|
export default DeltaCalculator;
|
|
@@ -182,7 +182,7 @@ export default class DeltaCalculator<T> extends EventEmitter {
|
|
|
182
182
|
|
|
183
183
|
#shouldReset(
|
|
184
184
|
canonicalPath: string,
|
|
185
|
-
metadata: {
|
|
185
|
+
metadata: {readonly isSymlink: boolean, ...},
|
|
186
186
|
): boolean {
|
|
187
187
|
if (metadata.isSymlink) {
|
|
188
188
|
return true;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<fc329765599e313b7d0cb6b45b7bbbdc>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/DeltaBundler/Graph.js
|
|
@@ -15,36 +15,12 @@
|
|
|
15
15
|
* yarn run build-ts-defs (OSS)
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Portions of this code are based on the Synchronous Cycle Collection
|
|
20
|
-
* algorithm described in:
|
|
21
|
-
*
|
|
22
|
-
* David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in
|
|
23
|
-
* Reference Counted Systems. In Proceedings of the 15th European Conference on
|
|
24
|
-
* Object-Oriented Programming (ECOOP '01). Springer-Verlag, Berlin,
|
|
25
|
-
* Heidelberg, 207–235.
|
|
26
|
-
*
|
|
27
|
-
* Notable differences from the algorithm in the paper:
|
|
28
|
-
* 1. Our implementation uses the inverseDependencies set (which we already
|
|
29
|
-
* have to maintain) instead of a separate refcount variable. A module's
|
|
30
|
-
* reference count is equal to the size of its inverseDependencies set, plus
|
|
31
|
-
* 1 if it's an entry point of the graph.
|
|
32
|
-
* 2. We keep the "root buffer" (possibleCycleRoots) free of duplicates by
|
|
33
|
-
* making it a Set, instead of storing a "buffered" flag on each node.
|
|
34
|
-
* 3. On top of tracking edges between nodes, we also count references between
|
|
35
|
-
* nodes and entries in the importBundleNodes set.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
import type {RequireContext} from '../lib/contextModule';
|
|
39
18
|
import type {
|
|
40
19
|
Dependencies,
|
|
41
|
-
Dependency,
|
|
42
20
|
GraphInputOptions,
|
|
43
21
|
MixedOutput,
|
|
44
22
|
Module,
|
|
45
|
-
ModuleData,
|
|
46
23
|
Options,
|
|
47
|
-
ResolvedDependency,
|
|
48
24
|
TransformInputOptions,
|
|
49
25
|
} from './types';
|
|
50
26
|
|
|
@@ -55,22 +31,6 @@ export type Result<T> = {
|
|
|
55
31
|
modified: Map<string, Module<T>>;
|
|
56
32
|
deleted: Set<string>;
|
|
57
33
|
};
|
|
58
|
-
type Delta<T> = Readonly<{
|
|
59
|
-
added: Set<string>;
|
|
60
|
-
touched: Set<string>;
|
|
61
|
-
deleted: Set<string>;
|
|
62
|
-
updatedModuleData: ReadonlyMap<string, ModuleData<T>>;
|
|
63
|
-
baseModuleData: Map<string, ModuleData<T>>;
|
|
64
|
-
errors: ReadonlyMap<string, Error>;
|
|
65
|
-
}>;
|
|
66
|
-
type InternalOptions<T> = Readonly<{
|
|
67
|
-
lazy: boolean;
|
|
68
|
-
onDependencyAdd: () => unknown;
|
|
69
|
-
onDependencyAdded: () => unknown;
|
|
70
|
-
resolve: Options<T>['resolve'];
|
|
71
|
-
transform: Options<T>['transform'];
|
|
72
|
-
shallow: boolean;
|
|
73
|
-
}>;
|
|
74
34
|
export declare class Graph<T = MixedOutput> {
|
|
75
35
|
readonly entryPoints: ReadonlySet<string>;
|
|
76
36
|
readonly transformOptions: TransformInputOptions;
|
|
@@ -92,32 +52,6 @@ export declare class Graph<T = MixedOutput> {
|
|
|
92
52
|
options: Options<T>,
|
|
93
53
|
): Promise<Result<T>>;
|
|
94
54
|
initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
|
|
95
|
-
_buildDelta(
|
|
96
|
-
pathsToVisit: ReadonlySet<string>,
|
|
97
|
-
options: InternalOptions<T>,
|
|
98
|
-
moduleFilter?: (path: string) => boolean,
|
|
99
|
-
): Promise<Delta<T>>;
|
|
100
|
-
_recursivelyCommitModule(
|
|
101
|
-
path: string,
|
|
102
|
-
delta: Delta<T>,
|
|
103
|
-
options: InternalOptions<T>,
|
|
104
|
-
commitOptions?: Readonly<{onlyRemove: boolean}>,
|
|
105
|
-
): Module<T>;
|
|
106
|
-
_addDependency(
|
|
107
|
-
parentModule: Module<T>,
|
|
108
|
-
key: string,
|
|
109
|
-
dependency: Dependency,
|
|
110
|
-
requireContext: null | undefined | RequireContext,
|
|
111
|
-
delta: Delta<T>,
|
|
112
|
-
options: InternalOptions<T>,
|
|
113
|
-
): void;
|
|
114
|
-
_removeDependency(
|
|
115
|
-
parentModule: Module<T>,
|
|
116
|
-
key: string,
|
|
117
|
-
dependency: Dependency,
|
|
118
|
-
delta: Delta<T>,
|
|
119
|
-
options: InternalOptions<T>,
|
|
120
|
-
): void;
|
|
121
55
|
/**
|
|
122
56
|
* Collect a list of context modules which include a given file.
|
|
123
57
|
*/
|
|
@@ -136,39 +70,4 @@ export declare class Graph<T = MixedOutput> {
|
|
|
136
70
|
* guarantee the same order between runs. This method mutates the passed graph.
|
|
137
71
|
*/
|
|
138
72
|
reorderGraph(options: {shallow: boolean}): void;
|
|
139
|
-
_reorderDependencies(
|
|
140
|
-
module: Module<T>,
|
|
141
|
-
orderedDependencies: Map<string, Module<T>>,
|
|
142
|
-
options: {shallow: boolean},
|
|
143
|
-
): void;
|
|
144
|
-
/** Garbage collection functions */
|
|
145
|
-
|
|
146
|
-
_incrementImportBundleReference(
|
|
147
|
-
dependency: ResolvedDependency,
|
|
148
|
-
parentModule: Module<T>,
|
|
149
|
-
): void;
|
|
150
|
-
_decrementImportBundleReference(
|
|
151
|
-
dependency: ResolvedDependency,
|
|
152
|
-
parentModule: Module<T>,
|
|
153
|
-
): void;
|
|
154
|
-
_markModuleInUse(module: Module<T>): void;
|
|
155
|
-
_children(
|
|
156
|
-
module: Module<T>,
|
|
157
|
-
options: InternalOptions<T>,
|
|
158
|
-
): Iterator<Module<T>>;
|
|
159
|
-
_moduleSnapshot(module: Module<T>): ModuleData<T>;
|
|
160
|
-
_releaseModule(
|
|
161
|
-
module: Module<T>,
|
|
162
|
-
delta: Delta<T>,
|
|
163
|
-
options: InternalOptions<T>,
|
|
164
|
-
): void;
|
|
165
|
-
_freeModule(module: Module<T>, delta: Delta<T>): void;
|
|
166
|
-
_markAsPossibleCycleRoot(module: Module<T>): void;
|
|
167
|
-
_collectCycles(delta: Delta<T>, options: InternalOptions<T>): void;
|
|
168
|
-
_markGray(module: Module<T>, options: InternalOptions<T>): void;
|
|
169
|
-
_scan(module: Module<T>, options: InternalOptions<T>): void;
|
|
170
|
-
_scanBlack(module: Module<T>, options: InternalOptions<T>): void;
|
|
171
|
-
_collectWhite(module: Module<T>, delta: Delta<T>): void;
|
|
172
|
-
|
|
173
|
-
/** End of garbage collection functions */
|
|
174
73
|
}
|
|
@@ -130,10 +130,10 @@ function isWeakOrLazy<T>(
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
export class Graph<T = MixedOutput> {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
readonly entryPoints: ReadonlySet<string>;
|
|
134
|
+
readonly transformOptions: TransformInputOptions;
|
|
135
|
+
readonly dependencies: Dependencies<T> = new Map();
|
|
136
|
+
readonly #importBundleNodes: Map<
|
|
137
137
|
string,
|
|
138
138
|
Readonly<{
|
|
139
139
|
inverseDependencies: CountingSet<string>,
|
|
@@ -141,9 +141,9 @@ export class Graph<T = MixedOutput> {
|
|
|
141
141
|
> = new Map();
|
|
142
142
|
|
|
143
143
|
/// GC state for nodes in the graph (this.dependencies)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
readonly #gc: {
|
|
145
|
+
readonly color: Map<string, NodeColor>,
|
|
146
|
+
readonly possibleCycleRoots: Set<string>,
|
|
147
147
|
} = {
|
|
148
148
|
color: new Map(),
|
|
149
149
|
possibleCycleRoots: new Set(),
|
|
@@ -16,7 +16,7 @@ import {getJsOutput, isJsModule} from './helpers/js';
|
|
|
16
16
|
|
|
17
17
|
type Options = {
|
|
18
18
|
platform: ?string,
|
|
19
|
-
|
|
19
|
+
readonly processModuleFilter: (module: Module<>) => boolean,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export default async function getAllFiles(
|
|
@@ -17,7 +17,7 @@ import {getJsOutput, isJsModule} from './helpers/js';
|
|
|
17
17
|
import path from 'path';
|
|
18
18
|
|
|
19
19
|
type Options = {
|
|
20
|
-
|
|
20
|
+
readonly processModuleFilter: (module: Module<>) => boolean,
|
|
21
21
|
assetPlugins: ReadonlyArray<string>,
|
|
22
22
|
platform: ?string,
|
|
23
23
|
projectRoot: string,
|
|
@@ -18,16 +18,16 @@ import type {
|
|
|
18
18
|
import {getJsOutput, isJsModule} from './helpers/js';
|
|
19
19
|
|
|
20
20
|
export type ExplodedSourceMap = ReadonlyArray<{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
readonly map: Array<MetroSourceMapSegmentTuple>,
|
|
22
|
+
readonly firstLine1Based: number,
|
|
23
|
+
readonly functionMap: ?FBSourceFunctionMap,
|
|
24
|
+
readonly path: string,
|
|
25
25
|
}>;
|
|
26
26
|
|
|
27
27
|
export function getExplodedSourceMap(
|
|
28
28
|
modules: ReadonlyArray<Module<>>,
|
|
29
29
|
options: {
|
|
30
|
-
|
|
30
|
+
readonly processModuleFilter: (module: Module<>) => boolean,
|
|
31
31
|
},
|
|
32
32
|
): ExplodedSourceMap {
|
|
33
33
|
const modulesToProcess = modules
|
|
@@ -20,18 +20,18 @@ import {getJsOutput} from './js';
|
|
|
20
20
|
export default function getSourceMapInfo(
|
|
21
21
|
module: Module<>,
|
|
22
22
|
options: {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
readonly excludeSource: boolean,
|
|
24
|
+
readonly shouldAddToIgnoreList: (Module<>) => boolean,
|
|
25
25
|
getSourceUrl: ?(module: Module<>) => string,
|
|
26
26
|
},
|
|
27
27
|
): {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
readonly map: Array<MetroSourceMapSegmentTuple>,
|
|
29
|
+
readonly functionMap: ?FBSourceFunctionMap,
|
|
30
|
+
readonly code: string,
|
|
31
|
+
readonly path: string,
|
|
32
|
+
readonly source: string,
|
|
33
|
+
readonly lineCount: number,
|
|
34
|
+
readonly isIgnored: boolean,
|
|
35
35
|
} {
|
|
36
36
|
return {
|
|
37
37
|
...getJsOutput(module).data,
|
|
@@ -148,9 +148,9 @@ export default function hmrJSBundle(
|
|
|
148
148
|
graph: ReadOnlyGraph<>,
|
|
149
149
|
options: Options,
|
|
150
150
|
): {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
readonly added: ReadonlyArray<HmrModule>,
|
|
152
|
+
readonly deleted: ReadonlyArray<number>,
|
|
153
|
+
readonly modified: ReadonlyArray<HmrModule>,
|
|
154
154
|
} {
|
|
155
155
|
return {
|
|
156
156
|
added: generateModules(delta.added.values(), graph, options),
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<74d76149d62fc6d50282472fa1e271fe>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/DeltaBundler/Transformer.js
|
|
@@ -15,22 +15,14 @@
|
|
|
15
15
|
* yarn run build-ts-defs (OSS)
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type {
|
|
18
|
+
import type {TransformResultWithSource} from '../DeltaBundler';
|
|
19
19
|
import type {TransformOptions} from './Worker';
|
|
20
20
|
import type {ConfigT} from 'metro-config';
|
|
21
21
|
|
|
22
|
-
import WorkerFarm from './WorkerFarm';
|
|
23
|
-
import {Cache} from 'metro-cache';
|
|
24
|
-
|
|
25
22
|
type GetOrComputeSha1Fn = (
|
|
26
23
|
$$PARAM_0$$: string,
|
|
27
24
|
) => Promise<Readonly<{content?: Buffer; sha1: string}>>;
|
|
28
25
|
declare class Transformer {
|
|
29
|
-
_config: ConfigT;
|
|
30
|
-
_cache: Cache<TransformResult>;
|
|
31
|
-
_baseHash: string;
|
|
32
|
-
_getSha1: GetOrComputeSha1Fn;
|
|
33
|
-
_workerFarm: WorkerFarm;
|
|
34
26
|
constructor(
|
|
35
27
|
config: ConfigT,
|
|
36
28
|
opts: Readonly<{getOrComputeSha1: GetOrComputeSha1Fn}>,
|