metro 0.70.3 → 0.71.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 +20 -20
- package/src/Assets.js.flow +4 -4
- package/src/Bundler/util.js +1 -1
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js +17 -10
- package/src/Bundler.js.flow +19 -14
- package/src/DeltaBundler/DeltaCalculator.js +13 -17
- package/src/DeltaBundler/DeltaCalculator.js.flow +15 -20
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +2 -2
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +2 -2
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Worker.js.flow +4 -4
- package/src/DeltaBundler/WorkerFarm.js.flow +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +2 -2
- package/src/DeltaBundler/{traverseDependencies.js → graphOperations.js} +43 -32
- package/src/DeltaBundler/{traverseDependencies.js.flow → graphOperations.js.flow} +52 -37
- package/src/DeltaBundler/types.flow.js.flow +36 -30
- package/src/DeltaBundler.js +14 -6
- package/src/DeltaBundler.js.flow +14 -10
- package/src/HmrServer.js.flow +6 -6
- package/src/IncrementalBundler.js +1 -1
- package/src/IncrementalBundler.js.flow +8 -8
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +2 -2
- package/src/ModuleGraph/node-haste/node-haste.js +4 -4
- package/src/ModuleGraph/node-haste/node-haste.js.flow +13 -7
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +2 -2
- package/src/ModuleGraph/output/plain-bundle.js.flow +2 -2
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +8 -8
- package/src/ModuleGraph/output/util.js.flow +2 -2
- package/src/ModuleGraph/types.flow.js.flow +37 -37
- package/src/ModuleGraph/worker/collectDependencies.js.flow +2 -2
- package/src/Server/symbolicate.js.flow +1 -1
- package/src/Server.js.flow +18 -18
- package/src/commands/build.js.flow +2 -2
- package/src/commands/serve.js.flow +2 -2
- package/src/index.js +32 -18
- package/src/index.js.flow +42 -32
- package/src/lib/bundleToBytecode.js.flow +2 -2
- package/src/lib/bundleToString.js.flow +2 -2
- package/src/lib/getPreludeCode.js.flow +2 -2
- package/src/lib/transformHelpers.js.flow +2 -2
- package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -1
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +5 -12
- package/src/node-haste/DependencyGraph/createHasteMap.js +9 -7
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +6 -9
- package/src/node-haste/DependencyGraph.js +31 -27
- package/src/node-haste/DependencyGraph.js.flow +43 -37
- package/src/node-haste/ModuleCache.js.flow +1 -1
- package/src/node-haste/lib/AssetPaths.js.flow +2 -2
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +1 -1
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +2 -2
- package/src/shared/types.flow.js.flow +14 -14
- package/src/DeltaBundler/computeDelta.js +0 -42
- package/src/DeltaBundler/computeDelta.js.flow +0 -47
- package/src/node-haste/DependencyGraph/types.js +0 -10
- package/src/node-haste/DependencyGraph/types.js.flow +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.0",
|
|
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
|
"hermes-parser": "0.6.0",
|
|
35
35
|
"image-size": "^0.6.0",
|
|
36
36
|
"invariant": "^2.2.4",
|
|
37
|
-
"jest-haste-map": "^27.3.1",
|
|
38
37
|
"jest-worker": "^27.2.0",
|
|
39
38
|
"lodash.throttle": "^4.1.1",
|
|
40
|
-
"metro-babel-transformer": "0.
|
|
41
|
-
"metro-cache": "0.
|
|
42
|
-
"metro-cache-key": "0.
|
|
43
|
-
"metro-config": "0.
|
|
44
|
-
"metro-core": "0.
|
|
45
|
-
"metro-
|
|
46
|
-
"metro-
|
|
47
|
-
"metro-
|
|
48
|
-
"metro-
|
|
49
|
-
"metro-
|
|
50
|
-
"metro-
|
|
51
|
-
"metro-
|
|
52
|
-
"metro-
|
|
53
|
-
"metro-
|
|
54
|
-
"metro-transform-
|
|
39
|
+
"metro-babel-transformer": "0.71.0",
|
|
40
|
+
"metro-cache": "0.71.0",
|
|
41
|
+
"metro-cache-key": "0.71.0",
|
|
42
|
+
"metro-config": "0.71.0",
|
|
43
|
+
"metro-core": "0.71.0",
|
|
44
|
+
"metro-file-map": "0.71.0",
|
|
45
|
+
"metro-hermes-compiler": "0.71.0",
|
|
46
|
+
"metro-inspector-proxy": "0.71.0",
|
|
47
|
+
"metro-minify-uglify": "0.71.0",
|
|
48
|
+
"metro-react-native-babel-preset": "0.71.0",
|
|
49
|
+
"metro-resolver": "0.71.0",
|
|
50
|
+
"metro-runtime": "0.71.0",
|
|
51
|
+
"metro-source-map": "0.71.0",
|
|
52
|
+
"metro-symbolicate": "0.71.0",
|
|
53
|
+
"metro-transform-plugins": "0.71.0",
|
|
54
|
+
"metro-transform-worker": "0.71.0",
|
|
55
55
|
"mime-types": "^2.1.27",
|
|
56
56
|
"node-fetch": "^2.2.0",
|
|
57
57
|
"nullthrows": "^1.1.1",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"babel-jest": "^26.6.3",
|
|
71
71
|
"dedent": "^0.7.0",
|
|
72
72
|
"jest-snapshot": "^26.5.2",
|
|
73
|
-
"metro-memory-fs": "0.
|
|
74
|
-
"metro-react-native-babel-preset": "0.
|
|
75
|
-
"metro-react-native-babel-transformer": "0.
|
|
73
|
+
"metro-memory-fs": "0.71.0",
|
|
74
|
+
"metro-react-native-babel-preset": "0.71.0",
|
|
75
|
+
"metro-react-native-babel-transformer": "0.71.0",
|
|
76
76
|
"stack-trace": "^0.0.10"
|
|
77
77
|
},
|
|
78
78
|
"license": "MIT"
|
package/src/Assets.js.flow
CHANGED
|
@@ -23,13 +23,13 @@ const path = require('path');
|
|
|
23
23
|
const readDir = denodeify(fs.readdir);
|
|
24
24
|
const readFile = denodeify(fs.readFile);
|
|
25
25
|
|
|
26
|
-
export type AssetInfo = {
|
|
26
|
+
export type AssetInfo = {
|
|
27
27
|
+files: Array<string>,
|
|
28
28
|
+hash: string,
|
|
29
29
|
+name: string,
|
|
30
30
|
+scales: Array<number>,
|
|
31
31
|
+type: string,
|
|
32
|
-
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
export type AssetDataWithoutFiles = {
|
|
35
35
|
+__packager_asset: boolean,
|
|
@@ -84,7 +84,7 @@ function buildAssetMap(
|
|
|
84
84
|
dir: string,
|
|
85
85
|
files: $ReadOnlyArray<string>,
|
|
86
86
|
platform: ?string,
|
|
87
|
-
): Map<string, {
|
|
87
|
+
): Map<string, {files: Array<string>, scales: Array<number>}> {
|
|
88
88
|
const platforms = new Set(platform != null ? [platform] : []);
|
|
89
89
|
const assets = files.map((file: string) =>
|
|
90
90
|
AssetPaths.tryParse(file, platforms),
|
|
@@ -131,7 +131,7 @@ function getAssetKey(assetName: string, platform: ?string): string {
|
|
|
131
131
|
async function getAbsoluteAssetRecord(
|
|
132
132
|
assetPath: string,
|
|
133
133
|
platform: ?string = null,
|
|
134
|
-
): Promise<{
|
|
134
|
+
): Promise<{files: Array<string>, scales: Array<number>}> {
|
|
135
135
|
const filename = path.basename(assetPath);
|
|
136
136
|
const dir = path.dirname(assetPath);
|
|
137
137
|
const files = await readDir(dir);
|
package/src/Bundler/util.js
CHANGED
package/src/Bundler/util.js.flow
CHANGED
|
@@ -95,7 +95,7 @@ function generateRemoteAssetCodeFileAst(
|
|
|
95
95
|
|
|
96
96
|
const file = remoteFileMap[assetDescriptor.fileSystemLocation];
|
|
97
97
|
const descriptor = file && file[assetDescriptor.name];
|
|
98
|
-
const data = {};
|
|
98
|
+
const data: {[number]: string} = {};
|
|
99
99
|
|
|
100
100
|
if (!descriptor) {
|
|
101
101
|
return null;
|
|
@@ -155,7 +155,7 @@ function filterObject(
|
|
|
155
155
|
object: AssetDataWithoutFiles,
|
|
156
156
|
blockList: Set<string>,
|
|
157
157
|
): AssetDataFiltered {
|
|
158
|
-
const copied =
|
|
158
|
+
const copied = {...object};
|
|
159
159
|
for (const key of blockList) {
|
|
160
160
|
delete copied[key];
|
|
161
161
|
}
|
package/src/Bundler.js
CHANGED
|
@@ -13,17 +13,19 @@ const Transformer = require("./DeltaBundler/Transformer");
|
|
|
13
13
|
|
|
14
14
|
const DependencyGraph = require("./node-haste/DependencyGraph");
|
|
15
15
|
|
|
16
|
+
const { EventEmitter } = require("events");
|
|
17
|
+
|
|
16
18
|
class Bundler {
|
|
17
19
|
constructor(config, options) {
|
|
18
|
-
this.
|
|
19
|
-
this._readyPromise = this.
|
|
20
|
-
.
|
|
20
|
+
this._depGraph = new DependencyGraph(config, options);
|
|
21
|
+
this._readyPromise = this._depGraph
|
|
22
|
+
.ready()
|
|
23
|
+
.then(() => {
|
|
21
24
|
config.reporter.update({
|
|
22
25
|
type: "transformer_load_started",
|
|
23
26
|
});
|
|
24
|
-
this._transformer = new Transformer(
|
|
25
|
-
|
|
26
|
-
dependencyGraph.getSha1.bind(dependencyGraph)
|
|
27
|
+
this._transformer = new Transformer(config, (...args) =>
|
|
28
|
+
this._depGraph.getSha1(...args)
|
|
27
29
|
);
|
|
28
30
|
config.reporter.update({
|
|
29
31
|
type: "transformer_load_done",
|
|
@@ -38,22 +40,27 @@ class Bundler {
|
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
getWatcher() {
|
|
44
|
+
return this._depGraph.getWatcher();
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
async end() {
|
|
42
|
-
|
|
48
|
+
await this._depGraph.ready();
|
|
43
49
|
|
|
44
50
|
this._transformer.end();
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
this._depGraph.end();
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
async getDependencyGraph() {
|
|
50
|
-
|
|
56
|
+
await this._depGraph.ready();
|
|
57
|
+
return this._depGraph;
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
async transformFile(filePath, transformOptions) {
|
|
54
61
|
// We need to be sure that the DependencyGraph has been initialized.
|
|
55
62
|
// TODO: Remove this ugly hack!
|
|
56
|
-
await this.
|
|
63
|
+
await this._depGraph.ready();
|
|
57
64
|
return this._transformer.transformFile(filePath, transformOptions);
|
|
58
65
|
} // Waits for the bundler to become ready.
|
|
59
66
|
|
package/src/Bundler.js.flow
CHANGED
|
@@ -16,27 +16,27 @@ import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
|
16
16
|
|
|
17
17
|
const Transformer = require('./DeltaBundler/Transformer');
|
|
18
18
|
const DependencyGraph = require('./node-haste/DependencyGraph');
|
|
19
|
+
const {EventEmitter} = require('events');
|
|
19
20
|
|
|
20
|
-
export type BundlerOptions = $ReadOnly<{
|
|
21
|
+
export type BundlerOptions = $ReadOnly<{
|
|
21
22
|
hasReducedPerformance?: boolean,
|
|
22
23
|
watch?: boolean,
|
|
23
|
-
|
|
24
|
+
}>;
|
|
24
25
|
|
|
25
26
|
class Bundler {
|
|
26
|
-
|
|
27
|
+
_depGraph: DependencyGraph;
|
|
27
28
|
_readyPromise: Promise<void>;
|
|
28
29
|
_transformer: Transformer;
|
|
29
30
|
|
|
30
31
|
constructor(config: ConfigT, options?: BundlerOptions) {
|
|
31
|
-
this.
|
|
32
|
+
this._depGraph = new DependencyGraph(config, options);
|
|
32
33
|
|
|
33
|
-
this._readyPromise = this.
|
|
34
|
-
.
|
|
34
|
+
this._readyPromise = this._depGraph
|
|
35
|
+
.ready()
|
|
36
|
+
.then(() => {
|
|
35
37
|
config.reporter.update({type: 'transformer_load_started'});
|
|
36
|
-
this._transformer = new Transformer(
|
|
37
|
-
|
|
38
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
39
|
-
dependencyGraph.getSha1.bind(dependencyGraph),
|
|
38
|
+
this._transformer = new Transformer(config, (...args) =>
|
|
39
|
+
this._depGraph.getSha1(...args),
|
|
40
40
|
);
|
|
41
41
|
config.reporter.update({type: 'transformer_load_done'});
|
|
42
42
|
})
|
|
@@ -49,15 +49,20 @@ class Bundler {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
getWatcher(): EventEmitter {
|
|
53
|
+
return this._depGraph.getWatcher();
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
async end(): Promise<void> {
|
|
53
|
-
|
|
57
|
+
await this._depGraph.ready();
|
|
54
58
|
|
|
55
59
|
this._transformer.end();
|
|
56
|
-
|
|
60
|
+
this._depGraph.end();
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
async getDependencyGraph(): Promise<DependencyGraph> {
|
|
60
|
-
|
|
64
|
+
await this._depGraph.ready();
|
|
65
|
+
return this._depGraph;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
async transformFile(
|
|
@@ -66,7 +71,7 @@ class Bundler {
|
|
|
66
71
|
): Promise<TransformResultWithSource<>> {
|
|
67
72
|
// We need to be sure that the DependencyGraph has been initialized.
|
|
68
73
|
// TODO: Remove this ugly hack!
|
|
69
|
-
await this.
|
|
74
|
+
await this._depGraph.ready();
|
|
70
75
|
|
|
71
76
|
return this._transformer.transformFile(filePath, transformOptions);
|
|
72
77
|
}
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
|
+
createGraph,
|
|
13
14
|
initialTraverseDependencies,
|
|
14
15
|
reorderGraph,
|
|
15
16
|
traverseDependencies,
|
|
16
|
-
} = require("./
|
|
17
|
+
} = require("./graphOperations");
|
|
17
18
|
|
|
18
19
|
const { EventEmitter } = require("events");
|
|
19
20
|
/**
|
|
@@ -27,38 +28,33 @@ class DeltaCalculator extends EventEmitter {
|
|
|
27
28
|
_deletedFiles = new Set();
|
|
28
29
|
_modifiedFiles = new Set();
|
|
29
30
|
|
|
30
|
-
constructor(entryPoints,
|
|
31
|
+
constructor(entryPoints, changeEventSource, options) {
|
|
31
32
|
super();
|
|
32
33
|
this._options = options;
|
|
33
|
-
this.
|
|
34
|
-
this._graph = {
|
|
35
|
-
dependencies: new Map(),
|
|
34
|
+
this._changeEventSource = changeEventSource;
|
|
35
|
+
this._graph = createGraph({
|
|
36
36
|
entryPoints,
|
|
37
|
-
importBundleNames: new Set(),
|
|
38
37
|
transformOptions: this._options.transformOptions,
|
|
39
|
-
};
|
|
38
|
+
});
|
|
40
39
|
|
|
41
|
-
this.
|
|
42
|
-
.getWatcher()
|
|
43
|
-
.on("change", this._handleMultipleFileChanges);
|
|
40
|
+
this._changeEventSource.on("change", this._handleMultipleFileChanges);
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
46
43
|
* Stops listening for file changes and clears all the caches.
|
|
47
44
|
*/
|
|
48
45
|
|
|
49
46
|
end() {
|
|
50
|
-
this.
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
this._changeEventSource.removeListener(
|
|
48
|
+
"change",
|
|
49
|
+
this._handleMultipleFileChanges
|
|
50
|
+
);
|
|
53
51
|
|
|
54
52
|
this.removeAllListeners(); // Clean up all the cache data structures to deallocate memory.
|
|
55
53
|
|
|
56
|
-
this._graph = {
|
|
57
|
-
dependencies: new Map(),
|
|
54
|
+
this._graph = createGraph({
|
|
58
55
|
entryPoints: this._graph.entryPoints,
|
|
59
|
-
importBundleNames: new Set(),
|
|
60
56
|
transformOptions: this._options.transformOptions,
|
|
61
|
-
};
|
|
57
|
+
});
|
|
62
58
|
this._modifiedFiles = new Set();
|
|
63
59
|
this._deletedFiles = new Set();
|
|
64
60
|
}
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
import type DependencyGraph from '../node-haste/DependencyGraph';
|
|
14
13
|
import type {DeltaResult, Graph, Options} from './types.flow';
|
|
15
14
|
|
|
16
15
|
const {
|
|
16
|
+
createGraph,
|
|
17
17
|
initialTraverseDependencies,
|
|
18
18
|
reorderGraph,
|
|
19
19
|
traverseDependencies,
|
|
20
|
-
} = require('./
|
|
20
|
+
} = require('./graphOperations');
|
|
21
21
|
const {EventEmitter} = require('events');
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -27,7 +27,7 @@ const {EventEmitter} = require('events');
|
|
|
27
27
|
* traverse the whole dependency tree for trivial small changes.
|
|
28
28
|
*/
|
|
29
29
|
class DeltaCalculator<T> extends EventEmitter {
|
|
30
|
-
|
|
30
|
+
_changeEventSource: EventEmitter;
|
|
31
31
|
_options: Options<T>;
|
|
32
32
|
|
|
33
33
|
_currentBuildPromise: ?Promise<DeltaResult<T>>;
|
|
@@ -37,44 +37,39 @@ class DeltaCalculator<T> extends EventEmitter {
|
|
|
37
37
|
_graph: Graph<T>;
|
|
38
38
|
|
|
39
39
|
constructor(
|
|
40
|
-
entryPoints: $
|
|
41
|
-
|
|
40
|
+
entryPoints: $ReadOnlySet<string>,
|
|
41
|
+
changeEventSource: EventEmitter,
|
|
42
42
|
options: Options<T>,
|
|
43
43
|
) {
|
|
44
44
|
super();
|
|
45
45
|
|
|
46
46
|
this._options = options;
|
|
47
|
-
this.
|
|
47
|
+
this._changeEventSource = changeEventSource;
|
|
48
48
|
|
|
49
|
-
this._graph = {
|
|
50
|
-
dependencies: new Map(),
|
|
49
|
+
this._graph = createGraph({
|
|
51
50
|
entryPoints,
|
|
52
|
-
importBundleNames: new Set(),
|
|
53
51
|
transformOptions: this._options.transformOptions,
|
|
54
|
-
};
|
|
52
|
+
});
|
|
55
53
|
|
|
56
|
-
this.
|
|
57
|
-
.getWatcher()
|
|
58
|
-
.on('change', this._handleMultipleFileChanges);
|
|
54
|
+
this._changeEventSource.on('change', this._handleMultipleFileChanges);
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
/**
|
|
62
58
|
* Stops listening for file changes and clears all the caches.
|
|
63
59
|
*/
|
|
64
60
|
end(): void {
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
this._changeEventSource.removeListener(
|
|
62
|
+
'change',
|
|
63
|
+
this._handleMultipleFileChanges,
|
|
64
|
+
);
|
|
68
65
|
|
|
69
66
|
this.removeAllListeners();
|
|
70
67
|
|
|
71
68
|
// Clean up all the cache data structures to deallocate memory.
|
|
72
|
-
this._graph = {
|
|
73
|
-
dependencies: new Map(),
|
|
69
|
+
this._graph = createGraph({
|
|
74
70
|
entryPoints: this._graph.entryPoints,
|
|
75
|
-
importBundleNames: new Set(),
|
|
76
71
|
transformOptions: this._options.transformOptions,
|
|
77
|
-
};
|
|
72
|
+
});
|
|
78
73
|
this._modifiedFiles = new Set();
|
|
79
74
|
this._deletedFiles = new Set();
|
|
80
75
|
}
|
|
@@ -15,10 +15,10 @@ import type {Graph, Module} from '../types.flow';
|
|
|
15
15
|
const {getAssetFiles} = require('../../Assets');
|
|
16
16
|
const {getJsOutput, isJsModule} = require('./helpers/js');
|
|
17
17
|
|
|
18
|
-
type Options = {
|
|
18
|
+
type Options = {
|
|
19
19
|
platform: ?string,
|
|
20
20
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
21
|
-
|
|
21
|
+
};
|
|
22
22
|
|
|
23
23
|
async function getAllFiles(
|
|
24
24
|
pre: $ReadOnlyArray<Module<>>,
|
|
@@ -17,13 +17,13 @@ const {getAssetData} = require('../../Assets');
|
|
|
17
17
|
const {getJsOutput, isJsModule} = require('./helpers/js');
|
|
18
18
|
const path = require('path');
|
|
19
19
|
|
|
20
|
-
type Options = {
|
|
20
|
+
type Options = {
|
|
21
21
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
22
22
|
assetPlugins: $ReadOnlyArray<string>,
|
|
23
23
|
platform: ?string,
|
|
24
24
|
projectRoot: string,
|
|
25
25
|
publicPath: string,
|
|
26
|
-
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
async function getAssets(
|
|
29
29
|
dependencies: Dependencies<>,
|
|
@@ -18,18 +18,18 @@ import type {
|
|
|
18
18
|
|
|
19
19
|
const {getJsOutput, isJsModule} = require('./helpers/js');
|
|
20
20
|
|
|
21
|
-
export type ExplodedSourceMap = $ReadOnlyArray<{
|
|
21
|
+
export type ExplodedSourceMap = $ReadOnlyArray<{
|
|
22
22
|
+map: Array<MetroSourceMapSegmentTuple>,
|
|
23
23
|
+firstLine1Based: number,
|
|
24
24
|
+functionMap: ?FBSourceFunctionMap,
|
|
25
25
|
+path: string,
|
|
26
|
-
|
|
26
|
+
}>;
|
|
27
27
|
|
|
28
28
|
function getExplodedSourceMap(
|
|
29
29
|
modules: $ReadOnlyArray<Module<>>,
|
|
30
|
-
options: {
|
|
30
|
+
options: {
|
|
31
31
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
32
|
-
|
|
32
|
+
},
|
|
33
33
|
): ExplodedSourceMap {
|
|
34
34
|
const modulesToProcess = modules
|
|
35
35
|
.filter(isJsModule)
|
|
@@ -25,19 +25,19 @@ const {sourceMapObject} = require('./sourceMapObject');
|
|
|
25
25
|
const nullthrows = require('nullthrows');
|
|
26
26
|
const path = require('path');
|
|
27
27
|
|
|
28
|
-
type Options = {
|
|
28
|
+
type Options = {
|
|
29
29
|
...SerializerOptions,
|
|
30
30
|
+excludeSource: boolean,
|
|
31
31
|
+getTransformOptions: ?GetTransformOptions,
|
|
32
32
|
+platform: ?string,
|
|
33
|
-
|
|
33
|
+
};
|
|
34
34
|
|
|
35
|
-
export type RamBundleInfo = {
|
|
35
|
+
export type RamBundleInfo = {
|
|
36
36
|
getDependencies: string => Set<string>,
|
|
37
37
|
startupModules: $ReadOnlyArray<ModuleTransportLike>,
|
|
38
38
|
lazyModules: $ReadOnlyArray<ModuleTransportLike>,
|
|
39
39
|
groups: Map<number, Set<number>>,
|
|
40
|
-
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
async function getRamBundleInfo(
|
|
43
43
|
entryPoint: string,
|
|
@@ -144,10 +144,10 @@ async function _getRamOptions(
|
|
|
144
144
|
},
|
|
145
145
|
getDependencies: string => Iterable<string>,
|
|
146
146
|
getTransformOptions: ?GetTransformOptions,
|
|
147
|
-
): Promise<{
|
|
147
|
+
): Promise<{
|
|
148
148
|
+preloadedModules: {[string]: true, ...},
|
|
149
149
|
+ramGroups: Array<string>,
|
|
150
|
-
|
|
150
|
+
}> {
|
|
151
151
|
if (getTransformOptions == null) {
|
|
152
152
|
return {
|
|
153
153
|
preloadedModules: {},
|
|
@@ -20,17 +20,17 @@ const {getJsOutput} = require('./js');
|
|
|
20
20
|
|
|
21
21
|
function getSourceMapInfo(
|
|
22
22
|
module: Module<>,
|
|
23
|
-
options: {
|
|
23
|
+
options: {
|
|
24
24
|
+excludeSource: boolean,
|
|
25
|
-
|
|
26
|
-
): {
|
|
25
|
+
},
|
|
26
|
+
): {
|
|
27
27
|
+map: Array<MetroSourceMapSegmentTuple>,
|
|
28
28
|
+functionMap: ?FBSourceFunctionMap,
|
|
29
29
|
+code: string,
|
|
30
30
|
+path: string,
|
|
31
31
|
+source: string,
|
|
32
32
|
+lineCount: number,
|
|
33
|
-
|
|
33
|
+
} {
|
|
34
34
|
return {
|
|
35
35
|
...getJsOutput(module).data,
|
|
36
36
|
path: module.path,
|
|
@@ -21,12 +21,12 @@ function processBytecodeModules(
|
|
|
21
21
|
createModuleId,
|
|
22
22
|
dev,
|
|
23
23
|
projectRoot,
|
|
24
|
-
}: {
|
|
24
|
+
}: {
|
|
25
25
|
+filter?: (module: Module<>) => boolean,
|
|
26
26
|
+createModuleId: string => number,
|
|
27
27
|
+dev: boolean,
|
|
28
28
|
+projectRoot: string,
|
|
29
|
-
|
|
29
|
+
},
|
|
30
30
|
): $ReadOnlyArray<[Module<>, Array<Buffer>]> {
|
|
31
31
|
return [...modules]
|
|
32
32
|
.filter(isBytecodeModule)
|
|
@@ -21,12 +21,12 @@ function processModules(
|
|
|
21
21
|
createModuleId,
|
|
22
22
|
dev,
|
|
23
23
|
projectRoot,
|
|
24
|
-
}: {
|
|
24
|
+
}: {
|
|
25
25
|
+filter?: (module: Module<>) => boolean,
|
|
26
26
|
+createModuleId: string => number,
|
|
27
27
|
+dev: boolean,
|
|
28
28
|
+projectRoot: string,
|
|
29
|
-
|
|
29
|
+
},
|
|
30
30
|
): $ReadOnlyArray<[Module<>, string]> {
|
|
31
31
|
return [...modules]
|
|
32
32
|
.filter(isJsModule)
|
|
@@ -124,11 +124,11 @@ function hmrJSBundle(
|
|
|
124
124
|
delta: DeltaResult<>,
|
|
125
125
|
graph: Graph<>,
|
|
126
126
|
options: Options,
|
|
127
|
-
): {
|
|
127
|
+
): {
|
|
128
128
|
+added: $ReadOnlyArray<HmrModule>,
|
|
129
129
|
+deleted: $ReadOnlyArray<number>,
|
|
130
130
|
+modified: $ReadOnlyArray<HmrModule>,
|
|
131
|
-
|
|
131
|
+
} {
|
|
132
132
|
return {
|
|
133
133
|
added: generateModules(delta.added.values(), graph, options),
|
|
134
134
|
modified: generateModules(delta.modified.values(), graph, options),
|
|
@@ -25,10 +25,10 @@ function getSourceMapInfosImpl(
|
|
|
25
25
|
isBlocking: boolean,
|
|
26
26
|
onDone: ($ReadOnlyArray<ReturnType<typeof getSourceMapInfo>>) => void,
|
|
27
27
|
modules: $ReadOnlyArray<Module<>>,
|
|
28
|
-
options: {
|
|
28
|
+
options: {
|
|
29
29
|
+excludeSource: boolean,
|
|
30
30
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
31
|
-
|
|
31
|
+
},
|
|
32
32
|
): void {
|
|
33
33
|
const sourceMapInfos = [];
|
|
34
34
|
const modulesToProcess = modules
|
|
@@ -76,10 +76,10 @@ function getSourceMapInfosImpl(
|
|
|
76
76
|
|
|
77
77
|
function sourceMapGenerator(
|
|
78
78
|
modules: $ReadOnlyArray<Module<>>,
|
|
79
|
-
options: {
|
|
79
|
+
options: {
|
|
80
80
|
+excludeSource: boolean,
|
|
81
81
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
82
|
-
|
|
82
|
+
},
|
|
83
83
|
): ReturnType<typeof fromRawMappings> {
|
|
84
84
|
let sourceMapInfos;
|
|
85
85
|
getSourceMapInfosImpl(
|
|
@@ -100,10 +100,10 @@ function sourceMapGenerator(
|
|
|
100
100
|
|
|
101
101
|
async function sourceMapGeneratorNonBlocking(
|
|
102
102
|
modules: $ReadOnlyArray<Module<>>,
|
|
103
|
-
options: {
|
|
103
|
+
options: {
|
|
104
104
|
+excludeSource: boolean,
|
|
105
105
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
106
|
-
|
|
106
|
+
},
|
|
107
107
|
): ReturnType<typeof fromRawMappingsNonBlocking> {
|
|
108
108
|
const sourceMapInfos = await new Promise(resolve => {
|
|
109
109
|
getSourceMapInfosImpl(false, resolve, modules, options);
|
|
@@ -20,10 +20,10 @@ const {
|
|
|
20
20
|
|
|
21
21
|
function sourceMapObject(
|
|
22
22
|
modules: $ReadOnlyArray<Module<>>,
|
|
23
|
-
options: {
|
|
23
|
+
options: {
|
|
24
24
|
+excludeSource: boolean,
|
|
25
25
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
26
|
-
|
|
26
|
+
},
|
|
27
27
|
): MixedSourceMap {
|
|
28
28
|
const generator = sourceMapGenerator(modules, options);
|
|
29
29
|
return generator.toMap(undefined, {
|
|
@@ -33,10 +33,10 @@ function sourceMapObject(
|
|
|
33
33
|
|
|
34
34
|
async function sourceMapObjectNonBlocking(
|
|
35
35
|
modules: $ReadOnlyArray<Module<>>,
|
|
36
|
-
options: {
|
|
36
|
+
options: {
|
|
37
37
|
+excludeSource: boolean,
|
|
38
38
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
39
|
-
|
|
39
|
+
},
|
|
40
40
|
): Promise<MixedSourceMap> {
|
|
41
41
|
const generator = await sourceMapGeneratorNonBlocking(modules, options);
|
|
42
42
|
return generator.toMap(undefined, {
|
|
@@ -16,10 +16,10 @@ const {sourceMapGenerator} = require('./sourceMapGenerator');
|
|
|
16
16
|
|
|
17
17
|
function sourceMapString(
|
|
18
18
|
modules: $ReadOnlyArray<Module<>>,
|
|
19
|
-
options: {
|
|
19
|
+
options: {
|
|
20
20
|
+excludeSource: boolean,
|
|
21
21
|
+processModuleFilter: (module: Module<>) => boolean,
|
|
22
|
-
|
|
22
|
+
},
|
|
23
23
|
): string {
|
|
24
24
|
return sourceMapGenerator(modules, options).toString(undefined, {
|
|
25
25
|
excludeSource: options.excludeSource,
|
|
@@ -24,9 +24,9 @@ const path = require('path');
|
|
|
24
24
|
|
|
25
25
|
export type {JsTransformOptions as TransformOptions} from 'metro-transform-worker';
|
|
26
26
|
|
|
27
|
-
export type Worker = {
|
|
27
|
+
export type Worker = {
|
|
28
28
|
+transform: typeof transform,
|
|
29
|
-
|
|
29
|
+
};
|
|
30
30
|
|
|
31
31
|
type TransformerInterface = {
|
|
32
32
|
transform(
|
|
@@ -44,12 +44,12 @@ export type TransformerConfig = {
|
|
|
44
44
|
...
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
type Data = $ReadOnly<{
|
|
47
|
+
type Data = $ReadOnly<{
|
|
48
48
|
result: TransformResult<>,
|
|
49
49
|
sha1: string,
|
|
50
50
|
transformFileStartLogEntry: LogEntry,
|
|
51
51
|
transformFileEndLogEntry: LogEntry,
|
|
52
|
-
|
|
52
|
+
}>;
|
|
53
53
|
|
|
54
54
|
async function transform(
|
|
55
55
|
filename: string,
|