metro 0.66.2 → 0.69.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 -24
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +16 -15
- package/src/Bundler/util.js.flow +11 -10
- package/src/Bundler.js +21 -8
- package/src/Bundler.js.flow +19 -7
- package/src/DeltaBundler/DeltaCalculator.js +15 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +7 -7
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
- package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +6 -6
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +11 -12
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
- package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
- package/src/DeltaBundler/Transformer.js +9 -9
- package/src/DeltaBundler/Transformer.js.flow +7 -9
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +14 -17
- package/src/DeltaBundler/WorkerFarm.js.flow +7 -10
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
- package/src/DeltaBundler/computeDelta.js +2 -2
- package/src/DeltaBundler/computeDelta.js.flow +2 -2
- package/src/DeltaBundler/getTransformCacheKey.js +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
- package/src/DeltaBundler/mergeDeltas.js +2 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/DeltaBundler/traverseDependencies.js +22 -22
- package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
- package/src/DeltaBundler/types.flow.js +1 -1
- package/src/DeltaBundler/types.flow.js.flow +1 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +71 -55
- package/src/HmrServer.js.flow +40 -37
- package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler.js +44 -32
- package/src/IncrementalBundler.js.flow +30 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +2 -2
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +1 -1
- package/src/ModuleGraph/node-haste/Module.js +1 -1
- package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
- package/src/ModuleGraph/node-haste/Package.js +3 -3
- package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
- package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.js +42 -32
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -23
- package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
- package/src/ModuleGraph/output/plain-bundle.js +6 -6
- package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
- package/src/ModuleGraph/output/util.js +31 -30
- package/src/ModuleGraph/output/util.js.flow +15 -16
- package/src/ModuleGraph/silent-console.js +2 -2
- package/src/ModuleGraph/silent-console.js.flow +1 -1
- package/src/ModuleGraph/test-helpers.js +7 -7
- package/src/ModuleGraph/types.flow.js +1 -1
- package/src/ModuleGraph/types.flow.js.flow +7 -7
- package/src/ModuleGraph/worker/JsFileWrapping.js +7 -7
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
- package/src/ModuleGraph/worker/Platforms.js +2 -2
- package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
- package/src/ModuleGraph/worker/collectDependencies.js +24 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -17
- package/src/ModuleGraph/worker/generate.js +2 -2
- package/src/ModuleGraph/worker/generate.js.flow +3 -3
- package/src/ModuleGraph/worker/generateImportNames.js +5 -5
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
- package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
- package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
- package/src/Server/MultipartResponse.js +4 -8
- package/src/Server/symbolicate.js +8 -8
- package/src/Server/symbolicate.js.flow +17 -5
- package/src/Server.js +202 -150
- package/src/Server.js.flow +129 -87
- package/src/cli-utils.js +4 -4
- package/src/cli-utils.js.flow +15 -13
- package/src/cli.js +4 -4
- package/src/cli.js.flow +2 -4
- package/src/commands/build.js +23 -24
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +25 -19
- package/src/commands/serve.js +17 -18
- package/src/commands/serve.js.flow +6 -9
- package/src/index.js +116 -51
- package/src/index.js.flow +107 -41
- package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Bar.js +2 -2
- package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Foo.js +2 -2
- package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestBundle.js +3 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +3 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +8 -8
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/polyfill.js +1 -1
- package/src/integration_tests/execBundle.js +2 -2
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/integration_tests/metro.config.js +8 -8
- package/src/lib/BatchProcessor.js +3 -3
- package/src/lib/BatchProcessor.js.flow +1 -1
- package/src/lib/JsonReporter.js +2 -2
- package/src/lib/JsonReporter.js.flow +1 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +14 -14
- package/src/lib/TerminalReporter.js.flow +9 -10
- package/src/lib/bundleToBytecode.js +6 -7
- package/src/lib/bundleToBytecode.js.flow +8 -7
- package/src/lib/bundleToString.js +3 -3
- package/src/lib/bundleToString.js.flow +5 -4
- package/src/lib/countLines.js +3 -7
- package/src/lib/countLines.js.flow +4 -7
- package/src/lib/createModuleIdFactory.js +2 -2
- package/src/lib/createModuleIdFactory.js.flow +1 -1
- package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
- package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +12 -21
- package/src/lib/debounceAsyncQueue.js +2 -2
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +21 -21
- package/src/lib/formatBundlingError.js.flow +6 -8
- package/src/lib/getAppendScripts.js +26 -27
- package/src/lib/getAppendScripts.js.flow +7 -8
- package/src/lib/getGraphId.js +3 -3
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getMaxWorkers.js +2 -2
- package/src/lib/getMaxWorkers.js.flow +1 -1
- package/src/lib/getPreludeCode.js +2 -2
- package/src/lib/getPreludeCode.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +15 -15
- package/src/lib/getPrependedScripts.js.flow +7 -8
- package/src/lib/logToConsole.js +1 -1
- package/src/lib/logToConsole.js.flow +3 -3
- package/src/lib/parseCustomTransformOptions.js +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +3 -3
- package/src/lib/parseOptionsFromUrl.js +7 -7
- package/src/lib/parseOptionsFromUrl.js.flow +29 -9
- package/src/lib/relativizeSourceMap.js +1 -1
- package/src/lib/relativizeSourceMap.js.flow +3 -3
- package/src/lib/reporting.js +5 -5
- package/src/lib/reporting.js.flow +16 -3
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +10 -10
- package/src/lib/transformHelpers.js.flow +5 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +46 -42
- package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
- package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
- package/src/node-haste/DependencyGraph/types.js.flow +88 -0
- package/src/node-haste/DependencyGraph.js +49 -117
- package/src/node-haste/DependencyGraph.js.flow +36 -111
- package/src/node-haste/Module.js +1 -1
- package/src/node-haste/Module.js.flow +3 -3
- package/src/node-haste/ModuleCache.js +54 -13
- package/src/node-haste/ModuleCache.js.flow +53 -12
- package/src/node-haste/Package.js +7 -9
- package/src/node-haste/Package.js.flow +1 -8
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +2 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +1 -1
- package/src/shared/output/RamBundle/as-assets.js +16 -17
- package/src/shared/output/RamBundle/as-assets.js.flow +11 -15
- package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
- package/src/shared/output/RamBundle/magic-number.js +1 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +21 -19
- package/src/shared/output/RamBundle/util.js.flow +5 -8
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +2 -2
- package/src/shared/output/RamBundle.js.flow +4 -5
- package/src/shared/output/bundle.js +6 -6
- package/src/shared/output/bundle.js.flow +4 -5
- package/src/shared/output/meta.js +4 -5
- package/src/shared/output/meta.js.flow +2 -4
- package/src/shared/output/unbundle.js +1 -1
- package/src/shared/output/unbundle.js.flow +1 -1
- package/src/shared/output/writeFile.js +1 -1
- package/src/shared/output/writeFile.js.flow +1 -1
- package/src/shared/types.flow.js +1 -1
- package/src/shared/types.flow.js.flow +2 -2
- package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
- package/src/node-haste/types.js +0 -10
- package/src/node-haste/types.js.flow +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const { Logger } = require("metro-core");
|
|
13
|
-
|
|
14
12
|
const JestWorker = require("jest-worker").default;
|
|
15
13
|
|
|
14
|
+
const { Logger } = require("metro-core");
|
|
15
|
+
|
|
16
16
|
class WorkerFarm {
|
|
17
17
|
constructor(config, transformerConfig) {
|
|
18
18
|
this._config = config;
|
|
@@ -25,16 +25,16 @@ class WorkerFarm {
|
|
|
25
25
|
this._config.maxWorkers
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
worker.getStdout().on("data", chunk => {
|
|
28
|
+
worker.getStdout().on("data", (chunk) => {
|
|
29
29
|
this._config.reporter.update({
|
|
30
30
|
type: "worker_stdout_chunk",
|
|
31
|
-
chunk: chunk.toString("utf8")
|
|
31
|
+
chunk: chunk.toString("utf8"),
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
-
worker.getStderr().on("data", chunk => {
|
|
34
|
+
worker.getStderr().on("data", (chunk) => {
|
|
35
35
|
this._config.reporter.update({
|
|
36
36
|
type: "worker_stderr_chunk",
|
|
37
|
-
chunk: chunk.toString("utf8")
|
|
37
|
+
chunk: chunk.toString("utf8"),
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
this._worker = worker;
|
|
@@ -62,7 +62,7 @@ class WorkerFarm {
|
|
|
62
62
|
Logger.log(data.transformFileEndLogEntry);
|
|
63
63
|
return {
|
|
64
64
|
result: data.result,
|
|
65
|
-
sha1: data.sha1
|
|
65
|
+
sha1: data.sha1,
|
|
66
66
|
};
|
|
67
67
|
} catch (err) {
|
|
68
68
|
if (err.loc) {
|
|
@@ -77,7 +77,7 @@ class WorkerFarm {
|
|
|
77
77
|
const env = {
|
|
78
78
|
...process.env,
|
|
79
79
|
// Force color to print syntax highlighted code frames.
|
|
80
|
-
FORCE_COLOR: 1
|
|
80
|
+
FORCE_COLOR: 1,
|
|
81
81
|
};
|
|
82
82
|
return new JestWorker(workerPath, {
|
|
83
83
|
computeWorkerKey: this._config.stickyWorkers // $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
@@ -85,9 +85,9 @@ class WorkerFarm {
|
|
|
85
85
|
: undefined,
|
|
86
86
|
exposedMethods,
|
|
87
87
|
forkOptions: {
|
|
88
|
-
env
|
|
88
|
+
env,
|
|
89
89
|
},
|
|
90
|
-
numWorkers
|
|
90
|
+
numWorkers,
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -105,11 +105,8 @@ class WorkerFarm {
|
|
|
105
105
|
_formatGenericError(err, filename) {
|
|
106
106
|
const error = new TransformError(`${filename}: ${err.message}`);
|
|
107
107
|
return Object.assign(error, {
|
|
108
|
-
stack: (err.stack || "")
|
|
109
|
-
|
|
110
|
-
.slice(0, -1)
|
|
111
|
-
.join("\n"),
|
|
112
|
-
lineNumber: 0
|
|
108
|
+
stack: (err.stack || "").split("\n").slice(0, -1).join("\n"),
|
|
109
|
+
lineNumber: 0,
|
|
113
110
|
});
|
|
114
111
|
}
|
|
115
112
|
|
|
@@ -125,7 +122,7 @@ class WorkerFarm {
|
|
|
125
122
|
snippet: err.codeFrame,
|
|
126
123
|
lineNumber: err.loc.line,
|
|
127
124
|
column: err.loc.column,
|
|
128
|
-
filename
|
|
125
|
+
filename,
|
|
129
126
|
});
|
|
130
127
|
}
|
|
131
128
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const {Logger} = require('metro-core');
|
|
14
|
-
const JestWorker = require('jest-worker').default;
|
|
15
|
-
|
|
16
|
-
import type {Readable} from 'stream';
|
|
17
13
|
import type {TransformResult} from '../DeltaBundler';
|
|
18
|
-
import type {
|
|
14
|
+
import type {TransformerConfig, TransformOptions, Worker} from './Worker';
|
|
19
15
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
16
|
+
import type {Readable} from 'stream';
|
|
17
|
+
|
|
18
|
+
const JestWorker = require('jest-worker').default;
|
|
19
|
+
const {Logger} = require('metro-core');
|
|
20
20
|
|
|
21
21
|
type WorkerInterface = {|
|
|
22
22
|
getStdout(): Readable,
|
|
@@ -140,10 +140,7 @@ class WorkerFarm {
|
|
|
140
140
|
const error = new TransformError(`${filename}: ${err.message}`);
|
|
141
141
|
|
|
142
142
|
return Object.assign(error, {
|
|
143
|
-
stack: (err.stack || '')
|
|
144
|
-
.split('\n')
|
|
145
|
-
.slice(0, -1)
|
|
146
|
-
.join('\n'),
|
|
143
|
+
stack: (err.stack || '').split('\n').slice(0, -1).join('\n'),
|
|
147
144
|
lineNumber: 0,
|
|
148
145
|
});
|
|
149
146
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -25,5 +25,5 @@ module.exports = {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return matches[1];
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -35,7 +35,7 @@ function computeDelta(entries1, entries2) {
|
|
|
35
35
|
return {
|
|
36
36
|
added: [...added.entries()],
|
|
37
37
|
modified: [...modified.entries()],
|
|
38
|
-
deleted: [...deleted]
|
|
38
|
+
deleted: [...deleted],
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {
|
|
14
|
-
ModuleMap,
|
|
15
14
|
DeltaBundle,
|
|
15
|
+
ModuleMap,
|
|
16
16
|
} from 'metro-runtime/src/modules/types.flow';
|
|
17
17
|
|
|
18
18
|
function computeDelta(entries1: ModuleMap, entries2: ModuleMap): DeltaBundle {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
+
const VERSION = require("../../package.json").version;
|
|
13
|
+
|
|
12
14
|
const crypto = require("crypto");
|
|
13
15
|
|
|
14
16
|
const getCacheKey = require("metro-cache-key");
|
|
15
17
|
|
|
16
|
-
const VERSION = require("../../package.json").version;
|
|
17
|
-
|
|
18
18
|
function getTransformCacheKey(opts) {
|
|
19
19
|
const { transformerPath, transformerConfig } = opts.transformerConfig; // eslint-disable-next-line no-useless-call
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ function getTransformCacheKey(opts) {
|
|
|
32
32
|
opts.cacheVersion,
|
|
33
33
|
getCacheKey([require.resolve(transformerPath)]),
|
|
34
34
|
transformerKey,
|
|
35
|
-
transformerConfig.globalPrefix
|
|
35
|
+
transformerConfig.globalPrefix,
|
|
36
36
|
].join("$")
|
|
37
37
|
)
|
|
38
38
|
.digest("hex");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,14 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const crypto = require('crypto');
|
|
14
|
-
const getCacheKey = require('metro-cache-key');
|
|
15
|
-
|
|
16
|
-
const VERSION = require('../../package.json').version;
|
|
17
|
-
|
|
18
13
|
import type {TransformerConfig} from './Worker';
|
|
19
14
|
import type {JsTransformerConfig} from 'metro-transform-worker';
|
|
20
15
|
|
|
16
|
+
const VERSION = require('../../package.json').version;
|
|
17
|
+
const crypto = require('crypto');
|
|
18
|
+
const getCacheKey = require('metro-cache-key');
|
|
19
|
+
|
|
21
20
|
type CacheKeyProvider = {
|
|
22
21
|
getCacheKey?: JsTransformerConfig => string,
|
|
23
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -63,7 +63,7 @@ function mergeDeltas(delta1, delta2) {
|
|
|
63
63
|
return {
|
|
64
64
|
added: [...added.entries()],
|
|
65
65
|
modified: [...modified.entries()],
|
|
66
|
-
deleted: [...deleted]
|
|
66
|
+
deleted: [...deleted],
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -16,7 +16,7 @@ function getInternalOptions({
|
|
|
16
16
|
resolve,
|
|
17
17
|
onProgress,
|
|
18
18
|
experimentalImportBundleSupport,
|
|
19
|
-
shallow
|
|
19
|
+
shallow,
|
|
20
20
|
}) {
|
|
21
21
|
let numProcessed = 0;
|
|
22
22
|
let total = 0;
|
|
@@ -26,7 +26,7 @@ function getInternalOptions({
|
|
|
26
26
|
resolve,
|
|
27
27
|
onDependencyAdd: () => onProgress && onProgress(numProcessed, ++total),
|
|
28
28
|
onDependencyAdded: () => onProgress && onProgress(++numProcessed, total),
|
|
29
|
-
shallow
|
|
29
|
+
shallow,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -46,7 +46,7 @@ async function traverseDependencies(paths, graph, options) {
|
|
|
46
46
|
added: new Set(),
|
|
47
47
|
modified: new Set(),
|
|
48
48
|
deleted: new Set(),
|
|
49
|
-
inverseDependencies: new Map()
|
|
49
|
+
inverseDependencies: new Map(),
|
|
50
50
|
};
|
|
51
51
|
const internalOptions = getInternalOptions(options);
|
|
52
52
|
|
|
@@ -99,7 +99,7 @@ async function traverseDependencies(paths, graph, options) {
|
|
|
99
99
|
return {
|
|
100
100
|
added,
|
|
101
101
|
modified,
|
|
102
|
-
deleted
|
|
102
|
+
deleted,
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -108,21 +108,21 @@ async function initialTraverseDependencies(graph, options) {
|
|
|
108
108
|
added: new Set(),
|
|
109
109
|
modified: new Set(),
|
|
110
110
|
deleted: new Set(),
|
|
111
|
-
inverseDependencies: new Map()
|
|
111
|
+
inverseDependencies: new Map(),
|
|
112
112
|
};
|
|
113
113
|
const internalOptions = getInternalOptions(options);
|
|
114
114
|
await Promise.all(
|
|
115
|
-
graph.entryPoints.map(path =>
|
|
115
|
+
graph.entryPoints.map((path) =>
|
|
116
116
|
traverseDependenciesForSingleFile(path, graph, delta, internalOptions)
|
|
117
117
|
)
|
|
118
118
|
);
|
|
119
119
|
reorderGraph(graph, {
|
|
120
|
-
shallow: options.shallow
|
|
120
|
+
shallow: options.shallow,
|
|
121
121
|
});
|
|
122
122
|
return {
|
|
123
123
|
added: graph.dependencies,
|
|
124
124
|
modified: new Map(),
|
|
125
|
-
deleted: new Set()
|
|
125
|
+
deleted: new Set(),
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -144,7 +144,7 @@ async function processModule(path, graph, delta, options) {
|
|
|
144
144
|
);
|
|
145
145
|
const previousModule = graph.dependencies.get(path) || {
|
|
146
146
|
inverseDependencies: delta.inverseDependencies.get(path) || new Set(),
|
|
147
|
-
path
|
|
147
|
+
path,
|
|
148
148
|
};
|
|
149
149
|
const previousDependencies = previousModule.dependencies || new Map(); // Update the module information.
|
|
150
150
|
|
|
@@ -152,7 +152,7 @@ async function processModule(path, graph, delta, options) {
|
|
|
152
152
|
...previousModule,
|
|
153
153
|
dependencies: new Map(),
|
|
154
154
|
getSource: result.getSource,
|
|
155
|
-
output: result.output
|
|
155
|
+
output: result.output,
|
|
156
156
|
};
|
|
157
157
|
graph.dependencies.set(module.path, module);
|
|
158
158
|
|
|
@@ -255,7 +255,7 @@ function getAllTopLevelInverseDependencies(
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
return Array.from(inverseDependencies)
|
|
258
|
-
.filter(inverseDep => graph.dependencies.has(inverseDep))
|
|
258
|
+
.filter((inverseDep) => graph.dependencies.has(inverseDep))
|
|
259
259
|
.reduce((acc, inverseDep) => {
|
|
260
260
|
const mod = graph.dependencies.get(inverseDep);
|
|
261
261
|
|
|
@@ -268,7 +268,7 @@ function getAllTopLevelInverseDependencies(
|
|
|
268
268
|
graph,
|
|
269
269
|
inverseDep,
|
|
270
270
|
visited
|
|
271
|
-
).forEach(x => {
|
|
271
|
+
).forEach((x) => {
|
|
272
272
|
acc.add(x);
|
|
273
273
|
});
|
|
274
274
|
return acc;
|
|
@@ -305,7 +305,7 @@ function canSafelyRemoveFromParentModule(
|
|
|
305
305
|
|
|
306
306
|
const undeletedInverseDependencies = Array.from(
|
|
307
307
|
topInverseDependencies
|
|
308
|
-
).filter(x => !delta.deleted.has(x));
|
|
308
|
+
).filter((x) => !delta.deleted.has(x));
|
|
309
309
|
/**
|
|
310
310
|
* We can only mark the `visited` Set of modules to be safely removable if
|
|
311
311
|
* 1. We do not have top a level module to compare with parentModule.
|
|
@@ -320,7 +320,7 @@ function canSafelyRemoveFromParentModule(
|
|
|
320
320
|
undeletedInverseDependencies[0] === parentModule);
|
|
321
321
|
|
|
322
322
|
if (canSafelyRemove) {
|
|
323
|
-
visited.forEach(mod => {
|
|
323
|
+
visited.forEach((mod) => {
|
|
324
324
|
canBeRemovedSafely.add(mod);
|
|
325
325
|
});
|
|
326
326
|
}
|
|
@@ -368,11 +368,11 @@ function removeDependency(
|
|
|
368
368
|
|
|
369
369
|
Array.from(module.dependencies.values())
|
|
370
370
|
.filter(
|
|
371
|
-
dependency =>
|
|
371
|
+
(dependency) =>
|
|
372
372
|
!delta.deleted.has(dependency.absolutePath) &&
|
|
373
373
|
dependency.absolutePath !== parentModule.path
|
|
374
374
|
)
|
|
375
|
-
.forEach(dependency =>
|
|
375
|
+
.forEach((dependency) =>
|
|
376
376
|
removeDependency(
|
|
377
377
|
module,
|
|
378
378
|
dependency.absolutePath,
|
|
@@ -394,8 +394,8 @@ function resolveDependencies(parentPath, dependencies, options) {
|
|
|
394
394
|
relativePath,
|
|
395
395
|
{
|
|
396
396
|
absolutePath: options.resolve(parentPath, relativePath),
|
|
397
|
-
data: result
|
|
398
|
-
}
|
|
397
|
+
data: result,
|
|
398
|
+
},
|
|
399
399
|
];
|
|
400
400
|
} catch (error) {
|
|
401
401
|
// Ignore unavailable optional dependencies. They are guarded
|
|
@@ -426,7 +426,7 @@ function resolveDependencies(parentPath, dependencies, options) {
|
|
|
426
426
|
|
|
427
427
|
function reorderGraph(graph, options) {
|
|
428
428
|
const orderedDependencies = new Map();
|
|
429
|
-
graph.entryPoints.forEach(entryPoint => {
|
|
429
|
+
graph.entryPoints.forEach((entryPoint) => {
|
|
430
430
|
const mainModule = graph.dependencies.get(entryPoint);
|
|
431
431
|
|
|
432
432
|
if (!mainModule) {
|
|
@@ -447,7 +447,7 @@ function reorderDependencies(graph, module, orderedDependencies, options) {
|
|
|
447
447
|
orderedDependencies.set(module.path, module);
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
module.dependencies.forEach(dependency => {
|
|
450
|
+
module.dependencies.forEach((dependency) => {
|
|
451
451
|
const path = dependency.absolutePath;
|
|
452
452
|
const childModule = graph.dependencies.get(path);
|
|
453
453
|
|
|
@@ -466,5 +466,5 @@ function reorderDependencies(graph, module, orderedDependencies, options) {
|
|
|
466
466
|
module.exports = {
|
|
467
467
|
initialTraverseDependencies,
|
|
468
468
|
traverseDependencies,
|
|
469
|
-
reorderGraph
|
|
469
|
+
reorderGraph,
|
|
470
470
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const nullthrows = require('nullthrows');
|
|
14
|
-
|
|
15
13
|
import type {
|
|
16
14
|
Dependency,
|
|
17
15
|
Graph,
|
|
@@ -20,6 +18,8 @@ import type {
|
|
|
20
18
|
TransformResultDependency,
|
|
21
19
|
} from './types.flow';
|
|
22
20
|
|
|
21
|
+
const nullthrows = require('nullthrows');
|
|
22
|
+
|
|
23
23
|
type Result<T> = {
|
|
24
24
|
added: Map<string, Module<T>>,
|
|
25
25
|
modified: Map<string, Module<T>>,
|
package/src/DeltaBundler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -25,7 +25,7 @@ class DeltaBundler {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
end() {
|
|
28
|
-
this._deltaCalculators.forEach(deltaCalculator => deltaCalculator.end());
|
|
28
|
+
this._deltaCalculators.forEach((deltaCalculator) => deltaCalculator.end());
|
|
29
29
|
|
|
30
30
|
this._deltaCalculators = new Map();
|
|
31
31
|
}
|
|
@@ -35,7 +35,7 @@ class DeltaBundler {
|
|
|
35
35
|
const deltaCalculator = new DeltaCalculator(entryPoints, depGraph, options);
|
|
36
36
|
await deltaCalculator.getDelta({
|
|
37
37
|
reset: true,
|
|
38
|
-
shallow: options.shallow
|
|
38
|
+
shallow: options.shallow,
|
|
39
39
|
});
|
|
40
40
|
const graph = deltaCalculator.getGraph();
|
|
41
41
|
deltaCalculator.end();
|
|
@@ -49,7 +49,7 @@ class DeltaBundler {
|
|
|
49
49
|
const deltaCalculator = new DeltaCalculator(entryPoints, depGraph, options);
|
|
50
50
|
await deltaCalculator.getDelta({
|
|
51
51
|
reset: true,
|
|
52
|
-
shallow: options.shallow
|
|
52
|
+
shallow: options.shallow,
|
|
53
53
|
});
|
|
54
54
|
const graph = deltaCalculator.getGraph();
|
|
55
55
|
|
|
@@ -67,7 +67,7 @@ class DeltaBundler {
|
|
|
67
67
|
|
|
68
68
|
return await deltaCalculator.getDelta({
|
|
69
69
|
reset,
|
|
70
|
-
shallow
|
|
70
|
+
shallow,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
package/src/DeltaBundler.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const DeltaCalculator = require('./DeltaBundler/DeltaCalculator');
|
|
14
|
-
|
|
15
13
|
import type Bundler from './Bundler';
|
|
16
14
|
import type {
|
|
17
15
|
DeltaResult,
|
|
18
|
-
Graph,
|
|
19
16
|
Dependencies,
|
|
17
|
+
Graph,
|
|
20
18
|
// eslint-disable-next-line no-unused-vars
|
|
21
19
|
MixedOutput,
|
|
22
20
|
Options,
|
|
23
21
|
} from './DeltaBundler/types.flow';
|
|
24
22
|
|
|
23
|
+
const DeltaCalculator = require('./DeltaBundler/DeltaCalculator');
|
|
24
|
+
|
|
25
25
|
export type {
|
|
26
26
|
DeltaResult,
|
|
27
27
|
Graph,
|