metro 0.80.4 → 0.80.6
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 +16 -17
- package/src/Assets.js +0 -35
- package/src/Bundler/util.js +1 -29
- package/src/Bundler.js +1 -20
- package/src/DeltaBundler/DeltaCalculator.js +0 -86
- package/src/DeltaBundler/Graph.js +0 -197
- package/src/DeltaBundler/Serializers/baseJSBundle.js +0 -13
- package/src/DeltaBundler/Serializers/getAllFiles.js +0 -11
- package/src/DeltaBundler/Serializers/getAssets.js +0 -11
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +0 -11
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +0 -18
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +0 -11
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +0 -11
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +0 -14
- package/src/DeltaBundler/Serializers/helpers/js.js +0 -21
- package/src/DeltaBundler/Serializers/helpers/processModules.js +0 -11
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +0 -23
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +0 -16
- package/src/DeltaBundler/Serializers/sourceMapObject.js +0 -11
- package/src/DeltaBundler/Serializers/sourceMapString.js +0 -11
- package/src/DeltaBundler/Transformer.js +0 -30
- package/src/DeltaBundler/Worker.flow.js +0 -26
- package/src/DeltaBundler/Worker.flow.js.flow +2 -2
- package/src/DeltaBundler/Worker.js +0 -14
- package/src/DeltaBundler/WorkerFarm.js +1 -21
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +0 -14
- package/src/DeltaBundler/buildSubgraph.js +0 -24
- package/src/DeltaBundler/getTransformCacheKey.js +0 -13
- package/src/DeltaBundler/getTransformCacheKey.js.flow +1 -1
- package/src/DeltaBundler/mergeDeltas.js +0 -11
- package/src/DeltaBundler/types.flow.js +0 -11
- package/src/DeltaBundler.js +0 -21
- package/src/HmrServer.js +8 -39
- package/src/HmrServer.js.flow +8 -6
- package/src/IncrementalBundler/GraphNotFoundError.js +0 -11
- package/src/IncrementalBundler/ResourceNotFoundError.js +0 -11
- package/src/IncrementalBundler/RevisionNotFoundError.js +0 -11
- package/src/IncrementalBundler.js +0 -23
- package/src/ModuleGraph/test-helpers.js +0 -17
- package/src/ModuleGraph/worker/JsFileWrapping.js +1 -22
- package/src/ModuleGraph/worker/collectDependencies.js +1 -94
- package/src/ModuleGraph/worker/generateImportNames.js +0 -15
- package/src/Server/MultipartResponse.js +0 -13
- package/src/Server/symbolicate.js +2 -36
- package/src/Server.js +6 -83
- package/src/cli/parseKeyValueParamArray.js +0 -11
- package/src/cli-utils.js +0 -11
- package/src/cli.js +0 -13
- package/src/commands/build.js +0 -15
- package/src/commands/dependencies.js +1 -19
- package/src/commands/serve.js +0 -19
- package/src/index.flow.js +0 -31
- package/src/index.js +0 -14
- package/src/integration_tests/basic_bundle/AssetRegistry.js +0 -10
- package/src/integration_tests/basic_bundle/Bar.js +0 -10
- package/src/integration_tests/basic_bundle/ErrorBundle.js +0 -12
- package/src/integration_tests/basic_bundle/Foo.js +0 -10
- package/src/integration_tests/basic_bundle/TestBigInt.js +0 -12
- package/src/integration_tests/basic_bundle/TestBundle.js +0 -11
- package/src/integration_tests/basic_bundle/TestPolyfill.js +0 -10
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +0 -14
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js +0 -14
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js +0 -14
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js +1 -15
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js +0 -13
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js +0 -16
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +0 -14
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js +0 -13
- package/src/integration_tests/basic_bundle/import-export/export-1.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-2.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-3.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-4.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-5.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-6.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-null.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +0 -10
- package/src/integration_tests/basic_bundle/import-export/index.js +0 -10
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js +0 -10
- package/src/integration_tests/basic_bundle/polyfill.js +0 -12
- package/src/integration_tests/basic_bundle/require-context/conflict.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/empty.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/matching.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js +0 -11
- package/src/integration_tests/basic_bundle/require-context/subdir/a.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/subdir/b.js +0 -9
- package/src/integration_tests/basic_bundle/require-context/subdir/c.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js +0 -10
- package/src/integration_tests/basic_bundle/require-context/utils.js +0 -10
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js +0 -15
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js +0 -10
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js +0 -10
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js +0 -15
- package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js +0 -10
- package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js +0 -10
- package/src/integration_tests/execBundle.js +0 -11
- package/src/integration_tests/metro.config.js +0 -10
- package/src/lib/BatchProcessor.js +0 -23
- package/src/lib/CountingSet.js +0 -35
- package/src/lib/JsonReporter.js +0 -17
- package/src/lib/RamBundleParser.js +0 -23
- package/src/lib/TerminalReporter.js +0 -68
- package/src/lib/bundleToString.js +1 -19
- package/src/lib/contextModule.js +1 -31
- package/src/lib/contextModuleTemplates.js +0 -36
- package/src/lib/countLines.js +0 -11
- package/src/lib/createModuleIdFactory.js +0 -11
- package/src/lib/createWebsocketServer.js +0 -24
- package/src/lib/debounceAsyncQueue.js +0 -13
- package/src/lib/formatBundlingError.js +0 -14
- package/src/lib/getAppendScripts.js +0 -11
- package/src/lib/getGraphId.js +0 -11
- package/src/lib/getMaxWorkers.js +0 -11
- package/src/lib/getPreludeCode.js +0 -18
- package/src/lib/getPrependedScripts.js +0 -13
- package/src/lib/logToConsole.js +0 -18
- package/src/lib/parseCustomResolverOptions.js +0 -11
- package/src/lib/parseCustomTransformOptions.js +0 -12
- package/src/lib/parseOptionsFromUrl.js +1 -17
- package/src/lib/relativizeSourceMap.js +0 -12
- package/src/lib/reporting.js +0 -30
- package/src/lib/splitBundleOptions.js +0 -14
- package/src/lib/transformHelpers.js +0 -20
- package/src/node-haste/DependencyGraph/ModuleResolution.js +5 -64
- package/src/node-haste/DependencyGraph/createFileMap.js +0 -16
- package/src/node-haste/DependencyGraph.js +6 -46
- package/src/node-haste/DependencyGraph.js.flow +7 -4
- package/src/node-haste/Module.js +0 -11
- package/src/node-haste/ModuleCache.js +0 -20
- package/src/node-haste/Package.js +0 -11
- package/src/node-haste/lib/AssetPaths.js +0 -16
- package/src/node-haste/lib/parsePlatformFilePath.js +0 -16
- package/src/shared/output/RamBundle/as-assets.js +6 -29
- package/src/shared/output/RamBundle/as-indexed-file.js +0 -44
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +0 -13
- package/src/shared/output/RamBundle/magic-number.js +0 -11
- package/src/shared/output/RamBundle/util.js +1 -17
- package/src/shared/output/RamBundle/write-sourcemap.js +0 -12
- package/src/shared/output/RamBundle.js +0 -14
- package/src/shared/output/bundle.flow.js +0 -13
- package/src/shared/output/bundle.flow.js.flow +1 -1
- package/src/shared/output/bundle.js +0 -14
- package/src/shared/output/meta.js +0 -11
- package/src/shared/output/unbundle.js +0 -13
- package/src/shared/output/writeFile.js +0 -11
- package/src/shared/types.flow.js +0 -11
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
const invariant = require("invariant");
|
|
15
|
-
/**
|
|
16
|
-
* We batch items together trying to minimize their processing, for example as
|
|
17
|
-
* network queries. For that we wait a small moment before processing a batch.
|
|
18
|
-
* We limit also the number of items we try to process in a single batch so that
|
|
19
|
-
* if we have many items pending in a short amount of time, we can start
|
|
20
|
-
* processing right away.
|
|
21
|
-
*/
|
|
22
4
|
class BatchProcessor {
|
|
23
5
|
constructor(options, processBatch) {
|
|
24
6
|
this._options = options;
|
|
@@ -26,7 +8,6 @@ class BatchProcessor {
|
|
|
26
8
|
this._queue = [];
|
|
27
9
|
this._timeoutHandle = null;
|
|
28
10
|
this._currentProcessCount = 0;
|
|
29
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
30
11
|
this._processQueue = this._processQueue.bind(this);
|
|
31
12
|
}
|
|
32
13
|
_onBatchFinished() {
|
|
@@ -53,9 +34,7 @@ class BatchProcessor {
|
|
|
53
34
|
this._currentProcessCount++;
|
|
54
35
|
const jobs = this._queue.splice(0, this._options.maximumItems);
|
|
55
36
|
this._processBatch(jobs.map((job) => job.item)).then(
|
|
56
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
57
37
|
this._onBatchResults.bind(this, jobs),
|
|
58
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
59
38
|
this._onBatchError.bind(this, jobs)
|
|
60
39
|
);
|
|
61
40
|
}
|
|
@@ -63,13 +42,11 @@ class BatchProcessor {
|
|
|
63
42
|
_processQueueOnceReady() {
|
|
64
43
|
if (this._queue.length >= this._options.maximumItems) {
|
|
65
44
|
clearTimeout(this._timeoutHandle);
|
|
66
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
67
45
|
process.nextTick(this._processQueue);
|
|
68
46
|
return;
|
|
69
47
|
}
|
|
70
48
|
if (this._timeoutHandle == null) {
|
|
71
49
|
this._timeoutHandle = setTimeout(
|
|
72
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
73
50
|
this._processQueue,
|
|
74
51
|
this._options.maximumDelayMs
|
|
75
52
|
);
|
package/src/lib/CountingSet.js
CHANGED
|
@@ -4,22 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @format
|
|
15
|
-
* @oncall react_native
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A Set that only deletes a given item when the number of delete(item) calls
|
|
20
|
-
* matches the number of add(item) calls. Iteration and `size` are in terms of
|
|
21
|
-
* *unique* items.
|
|
22
|
-
*/
|
|
23
7
|
class CountingSet {
|
|
24
8
|
#map = new Map();
|
|
25
9
|
constructor(items) {
|
|
@@ -59,22 +43,9 @@ class CountingSet {
|
|
|
59
43
|
yield [item, item];
|
|
60
44
|
}
|
|
61
45
|
}
|
|
62
|
-
|
|
63
|
-
// Iterate over unique entries
|
|
64
|
-
// $FlowIssue[unsupported-syntax]
|
|
65
46
|
[Symbol.iterator]() {
|
|
66
47
|
return this.values();
|
|
67
48
|
}
|
|
68
|
-
|
|
69
|
-
/*::
|
|
70
|
-
// For Flow's benefit
|
|
71
|
-
@@iterator(): Iterator<T> {
|
|
72
|
-
return this.values();
|
|
73
|
-
}
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
// Number of unique entries
|
|
77
|
-
// $FlowIssue[unsafe-getters-setters]
|
|
78
49
|
get size() {
|
|
79
50
|
return this.#map.size;
|
|
80
51
|
}
|
|
@@ -89,12 +60,6 @@ class CountingSet {
|
|
|
89
60
|
callbackFn.call(thisArg, item, item, this);
|
|
90
61
|
}
|
|
91
62
|
}
|
|
92
|
-
|
|
93
|
-
// For Jest purposes. Ideally a custom serializer would be enough, but in
|
|
94
|
-
// practice there is hardcoded magic for Set in toEqual (etc) that we cannot
|
|
95
|
-
// extend to custom collection classes. Instead let's assume values are
|
|
96
|
-
// sortable ( = strings) and make this look like an array with some stable
|
|
97
|
-
// order.
|
|
98
63
|
toJSON() {
|
|
99
64
|
return [...this].sort();
|
|
100
65
|
}
|
package/src/lib/JsonReporter.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
class JsonReporter {
|
|
15
4
|
constructor(stream) {
|
|
16
5
|
this._stream = stream;
|
|
17
6
|
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* There is a special case for errors because they have non-enumerable fields.
|
|
21
|
-
* (Perhaps we should switch in favor of plain object?)
|
|
22
|
-
*/
|
|
23
7
|
update(event) {
|
|
24
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
25
8
|
if (Object.prototype.toString.call(event.error) === "[object Error]") {
|
|
26
9
|
event = Object.assign(event, {
|
|
27
10
|
message: event.error.message,
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
1
|
"use strict";
|
|
12
2
|
|
|
13
3
|
const MAGIC_NUMBER = require("../shared/output/RamBundle/magic-number");
|
|
14
4
|
const SIZEOF_UINT32 = 4;
|
|
15
5
|
const HEADER_SIZE = 3;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Implementation of a RAM bundle parser in JS.
|
|
19
|
-
*
|
|
20
|
-
* It receives a Buffer as an input and implements two main methods, which are
|
|
21
|
-
* able to run in constant time no matter the size of the bundle:
|
|
22
|
-
*
|
|
23
|
-
* getStartupCode(): returns the runtime and the startup code of the bundle.
|
|
24
|
-
* getModule(): returns the code for the specified module.
|
|
25
|
-
*/
|
|
26
6
|
class RamBundleParser {
|
|
27
7
|
constructor(buffer) {
|
|
28
8
|
this._buffer = buffer;
|
|
@@ -31,9 +11,6 @@ class RamBundleParser {
|
|
|
31
11
|
}
|
|
32
12
|
this._numModules = this._readPosition(1);
|
|
33
13
|
this._startupCodeLength = this._readPosition(2);
|
|
34
|
-
|
|
35
|
-
// The startup code begins after the table of contents, which contains the
|
|
36
|
-
// 3 fields on the header plus 2 entries per module.
|
|
37
14
|
this._startOffset = (HEADER_SIZE + this._numModules * 2) * SIZEOF_UINT32;
|
|
38
15
|
}
|
|
39
16
|
_readPosition(pos) {
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
const logToConsole = require("./logToConsole");
|
|
@@ -22,18 +11,7 @@ const GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT =
|
|
|
22
11
|
const DARK_BLOCK_CHAR = "\u2593";
|
|
23
12
|
const LIGHT_BLOCK_CHAR = "\u2591";
|
|
24
13
|
const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* We try to print useful information to the terminal for interactive builds.
|
|
28
|
-
* This implements the `Reporter` interface from the './reporting' module.
|
|
29
|
-
*/
|
|
30
14
|
class TerminalReporter {
|
|
31
|
-
/**
|
|
32
|
-
* The bundle builds for which we are actively maintaining the status on the
|
|
33
|
-
* terminal, ie. showing a progress bar. There can be several bundles being
|
|
34
|
-
* built at the same time.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
15
|
constructor(terminal) {
|
|
38
16
|
this._activeBundles = new Map();
|
|
39
17
|
this._scheduleUpdateBundleProgress = throttle((data) => {
|
|
@@ -44,13 +22,6 @@ class TerminalReporter {
|
|
|
44
22
|
}, 100);
|
|
45
23
|
this.terminal = terminal;
|
|
46
24
|
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Construct a message that represents the progress of a
|
|
50
|
-
* single bundle build, for example:
|
|
51
|
-
*
|
|
52
|
-
* BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)
|
|
53
|
-
*/
|
|
54
25
|
_getBundleStatusMessage(
|
|
55
26
|
{
|
|
56
27
|
bundleDetails: { entryFile, bundleType },
|
|
@@ -175,11 +146,6 @@ class TerminalReporter {
|
|
|
175
146
|
this.terminal.log(chalk.red(error.stack));
|
|
176
147
|
}
|
|
177
148
|
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* This function is only concerned with logging and should not do state
|
|
181
|
-
* or terminal status updates.
|
|
182
|
-
*/
|
|
183
149
|
_log(event) {
|
|
184
150
|
switch (event.type) {
|
|
185
151
|
case "initialize_started":
|
|
@@ -244,12 +210,6 @@ class TerminalReporter {
|
|
|
244
210
|
break;
|
|
245
211
|
}
|
|
246
212
|
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* We do not want to log the whole stacktrace for bundling error, because
|
|
250
|
-
* these are operational errors, not programming errors, and the stacktrace
|
|
251
|
-
* is not actionable to end users.
|
|
252
|
-
*/
|
|
253
213
|
_logBundlingError(error) {
|
|
254
214
|
if (error instanceof AmbiguousModuleResolutionError) {
|
|
255
215
|
const he = error.hasteError;
|
|
@@ -266,16 +226,12 @@ class TerminalReporter {
|
|
|
266
226
|
return;
|
|
267
227
|
}
|
|
268
228
|
let { message } = error;
|
|
269
|
-
|
|
270
|
-
// Do not log the stack trace for SyntaxError (because it will always be in
|
|
271
|
-
// the parser, which is not helpful).
|
|
272
229
|
if (!(error instanceof SyntaxError)) {
|
|
273
230
|
if (error.snippet == null && error.stack != null) {
|
|
274
231
|
message = error.stack;
|
|
275
232
|
}
|
|
276
233
|
}
|
|
277
234
|
if (error.filename && !message.includes(error.filename)) {
|
|
278
|
-
// $FlowFixMe[incompatible-type]
|
|
279
235
|
message += ` [${error.filename}]`;
|
|
280
236
|
}
|
|
281
237
|
if (error.snippet != null) {
|
|
@@ -292,12 +248,6 @@ class TerminalReporter {
|
|
|
292
248
|
this.terminal.log(`transform[${origin}]: ${line}`);
|
|
293
249
|
});
|
|
294
250
|
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* We use Math.pow(ratio, 2) to as a conservative measure of progress because
|
|
298
|
-
* we know the `totalCount` is going to progressively increase as well. We
|
|
299
|
-
* also prevent the ratio from going backwards.
|
|
300
|
-
*/
|
|
301
251
|
_updateBundleProgress({ buildID, transformedFileCount, totalFileCount }) {
|
|
302
252
|
const currentProgress = this._activeBundles.get(buildID);
|
|
303
253
|
if (currentProgress == null) {
|
|
@@ -312,11 +262,6 @@ class TerminalReporter {
|
|
|
312
262
|
totalFileCount,
|
|
313
263
|
});
|
|
314
264
|
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* This function is exclusively concerned with updating the internal state.
|
|
318
|
-
* No logging or status updates should be done at this point.
|
|
319
|
-
*/
|
|
320
265
|
_updateState(event) {
|
|
321
266
|
switch (event.type) {
|
|
322
267
|
case "bundle_build_done":
|
|
@@ -338,12 +283,6 @@ class TerminalReporter {
|
|
|
338
283
|
break;
|
|
339
284
|
}
|
|
340
285
|
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Return a status message that is always consistent with the current state
|
|
344
|
-
* of the application. Having this single function ensures we don't have
|
|
345
|
-
* different callsites overriding each other status messages.
|
|
346
|
-
*/
|
|
347
286
|
_getStatusMessage() {
|
|
348
287
|
return Array.from(this._activeBundles.entries())
|
|
349
288
|
.map(([_, progress]) =>
|
|
@@ -364,7 +303,6 @@ class TerminalReporter {
|
|
|
364
303
|
reporting.logWarning(this.terminal, message);
|
|
365
304
|
}
|
|
366
305
|
_logWatcherHealthCheckResult(result) {
|
|
367
|
-
// Don't be spammy; only report changes in status.
|
|
368
306
|
if (
|
|
369
307
|
!this._prevHealthCheckResult ||
|
|
370
308
|
result.type !== this._prevHealthCheckResult.type ||
|
|
@@ -376,7 +314,6 @@ class TerminalReporter {
|
|
|
376
314
|
const watcherName = "'" + (result.watcher ?? "unknown") + "'";
|
|
377
315
|
switch (result.type) {
|
|
378
316
|
case "success":
|
|
379
|
-
// Only report success after a prior failure.
|
|
380
317
|
if (this._prevHealthCheckResult) {
|
|
381
318
|
this.terminal.log(
|
|
382
319
|
chalk.green(`Watcher ${watcherName} is now healthy.`)
|
|
@@ -436,11 +373,6 @@ class TerminalReporter {
|
|
|
436
373
|
break;
|
|
437
374
|
}
|
|
438
375
|
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Single entry point for reporting events. That allows us to implement the
|
|
442
|
-
* corresponding JSON reporter easily and have a consistent reporting.
|
|
443
|
-
*/
|
|
444
376
|
update(event) {
|
|
445
377
|
if (event.type === "bundle_transform_progressed") {
|
|
446
378
|
this._scheduleUpdateBundleProgress(event);
|
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
|
-
/**
|
|
15
|
-
* Serializes a bundle into a plain JS bundle.
|
|
16
|
-
*/
|
|
17
3
|
function bundleToString(bundle) {
|
|
18
4
|
let code = bundle.pre.length > 0 ? bundle.pre + "\n" : "";
|
|
19
5
|
const modules = [];
|
|
20
|
-
const sortedModules = bundle.modules
|
|
21
|
-
.slice()
|
|
22
|
-
// The order of the modules needs to be deterministic in order for source
|
|
23
|
-
// maps to work properly.
|
|
24
|
-
.sort((a, b) => a[0] - b[0]);
|
|
6
|
+
const sortedModules = bundle.modules.slice().sort((a, b) => a[0] - b[0]);
|
|
25
7
|
for (const [id, moduleCode] of sortedModules) {
|
|
26
8
|
if (moduleCode.length > 0) {
|
|
27
9
|
code += moduleCode + "\n";
|
package/src/lib/contextModule.js
CHANGED
|
@@ -11,27 +11,10 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
11
11
|
function _interopRequireDefault(obj) {
|
|
12
12
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the MIT license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @format
|
|
22
|
-
* @oncall react_native
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
14
|
function toHash(value) {
|
|
26
|
-
// Use `hex` to ensure filepath safety.
|
|
27
15
|
return _crypto.default.createHash("sha1").update(value).digest("hex");
|
|
28
16
|
}
|
|
29
|
-
|
|
30
|
-
/** Given a fully qualified require context, return a virtual file path that ensures uniqueness between paths with different contexts. */
|
|
31
17
|
function deriveAbsolutePathFromContext(from, context) {
|
|
32
|
-
// Drop the trailing slash, require.context should always be matched against a folder
|
|
33
|
-
// and we want to normalize the folder name as much as possible to prevent duplicates.
|
|
34
|
-
// This also makes the files show up in the correct location when debugging in Chrome.
|
|
35
18
|
const filePath = from.endsWith(_path.default.sep) ? from.slice(0, -1) : from;
|
|
36
19
|
return (
|
|
37
20
|
filePath +
|
|
@@ -47,29 +30,16 @@ function deriveAbsolutePathFromContext(from, context) {
|
|
|
47
30
|
)
|
|
48
31
|
);
|
|
49
32
|
}
|
|
50
|
-
|
|
51
|
-
/** Match a file against a require context. */
|
|
52
33
|
function fileMatchesContext(testPath, context) {
|
|
53
|
-
// NOTE(EvanBacon): Ensure this logic is synchronized with the similar
|
|
54
|
-
// functionality in `metro-file-map/src/lib/TreeFS.js` (`matchFiles()`)
|
|
55
|
-
|
|
56
34
|
const filePath = _path.default.relative(
|
|
57
35
|
(0, _nullthrows.default)(context.from),
|
|
58
36
|
testPath
|
|
59
37
|
);
|
|
60
38
|
const filter = context.filter;
|
|
61
39
|
if (
|
|
62
|
-
// Ignore everything outside of the provided `root`.
|
|
63
40
|
!(filePath && !filePath.startsWith("..")) ||
|
|
64
|
-
// Prevent searching in child directories during a non-recursive search.
|
|
65
41
|
(!context.recursive && filePath.includes(_path.default.sep)) ||
|
|
66
|
-
|
|
67
|
-
!filter.test(
|
|
68
|
-
// NOTE(EvanBacon): Ensure files start with `./` for matching purposes
|
|
69
|
-
// this ensures packages work across Metro and Webpack (ex: Storybook for React DOM / React Native).
|
|
70
|
-
// `a/b.js` -> `./a/b.js`
|
|
71
|
-
"./" + filePath.replace(/\\/g, "/")
|
|
72
|
-
)
|
|
42
|
+
!filter.test("./" + filePath.replace(/\\/g, "/"))
|
|
73
43
|
) {
|
|
74
44
|
return false;
|
|
75
45
|
}
|
|
@@ -46,44 +46,20 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
46
46
|
}
|
|
47
47
|
return newObj;
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
51
|
-
*
|
|
52
|
-
* This source code is licensed under the MIT license found in the
|
|
53
|
-
* LICENSE file in the root directory of this source tree.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @format
|
|
57
|
-
* @oncall react_native
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
49
|
function createFileMap(modulePath, files, processModule) {
|
|
61
50
|
let mapString = "\n";
|
|
62
51
|
files
|
|
63
52
|
.slice()
|
|
64
|
-
// Sort for deterministic output
|
|
65
53
|
.sort()
|
|
66
54
|
.forEach((file) => {
|
|
67
55
|
let filePath = path.relative(modulePath, file);
|
|
68
56
|
if (os.platform() === "win32") {
|
|
69
57
|
filePath = filePath.replaceAll("\\", "/");
|
|
70
58
|
}
|
|
71
|
-
|
|
72
|
-
// NOTE(EvanBacon): I'd prefer we prevent the ability for a module to require itself (`require.context('./')`)
|
|
73
|
-
// but Webpack allows this, keeping it here provides better parity between bundlers.
|
|
74
|
-
|
|
75
|
-
// Ensure relative file paths start with `./` so they match the
|
|
76
|
-
// patterns (filters) used to include them.
|
|
77
59
|
if (!filePath.startsWith(".")) {
|
|
78
60
|
filePath = `./${filePath}`;
|
|
79
61
|
}
|
|
80
62
|
const key = JSON.stringify(filePath);
|
|
81
|
-
// NOTE(EvanBacon): Webpack uses `require.resolve` in order to load modules on demand,
|
|
82
|
-
// Metro doesn't have this functionality so it will use getters instead. Modules need to
|
|
83
|
-
// be loaded on demand because if we imported directly then users would get errors from importing
|
|
84
|
-
// a file without exports as soon as they create a new file and the context module is updated.
|
|
85
|
-
|
|
86
|
-
// NOTE: The values are set to `enumerable` so the `context.keys()` method works as expected.
|
|
87
63
|
mapString += ` ${key}: { enumerable: true, get() { return ${processModule(
|
|
88
64
|
file
|
|
89
65
|
)}; } },\n`;
|
|
@@ -137,16 +113,6 @@ metroContext.resolve = function metroContextResolve(request) {
|
|
|
137
113
|
|
|
138
114
|
module.exports = metroContext;`;
|
|
139
115
|
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Generate a context module as a virtual file string.
|
|
143
|
-
*
|
|
144
|
-
* @prop {ContextMode} mode indicates how the modules should be loaded.
|
|
145
|
-
* @prop {string} modulePath virtual file path for the virtual module. Example: `require.context('./src')` -> `'/path/to/project/src'`.
|
|
146
|
-
* @prop {string[]} files list of absolute file paths that must be exported from the context module. Example: `['/path/to/project/src/index.js']`.
|
|
147
|
-
*
|
|
148
|
-
* @returns a string representing a context module (virtual file contents).
|
|
149
|
-
*/
|
|
150
116
|
function getContextModuleTemplate(mode, modulePath, files) {
|
|
151
117
|
if (!files.length) {
|
|
152
118
|
return getEmptyContextModuleTemplate(modulePath);
|
|
@@ -156,8 +122,6 @@ function getContextModuleTemplate(mode, modulePath, files) {
|
|
|
156
122
|
return getLoadableContextModuleTemplate(
|
|
157
123
|
modulePath,
|
|
158
124
|
files,
|
|
159
|
-
// NOTE(EvanBacon): It's unclear if we should use `import` or `require` here so sticking
|
|
160
|
-
// with the more stable option (`require`) for now.
|
|
161
125
|
"require",
|
|
162
126
|
[
|
|
163
127
|
" // Here Promise.resolve().then() is used instead of new Promise() to prevent",
|
package/src/lib/countLines.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
const newline = /\r\n?|\n|\u2028|\u2029/g;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
function createModuleIdFactory() {
|
|
@@ -4,28 +4,6 @@ var _ws = _interopRequireDefault(require("ws"));
|
|
|
4
4
|
function _interopRequireDefault(obj) {
|
|
5
5
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @format
|
|
15
|
-
* @oncall react_native
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
|
|
20
|
-
* the received events on the given "websocketServer" parameter. It must be an
|
|
21
|
-
* object with the following fields:
|
|
22
|
-
*
|
|
23
|
-
* - onClientConnect
|
|
24
|
-
* - onClientError
|
|
25
|
-
* - onClientMessage
|
|
26
|
-
* - onClientDisconnect
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
7
|
module.exports = function createWebsocketServer({ websocketServer }) {
|
|
30
8
|
const wss = new _ws.default.Server({
|
|
31
9
|
noServer: true,
|
|
@@ -35,7 +13,6 @@ module.exports = function createWebsocketServer({ websocketServer }) {
|
|
|
35
13
|
const url = req.url;
|
|
36
14
|
const sendFn = (...args) => {
|
|
37
15
|
if (connected) {
|
|
38
|
-
// $FlowFixMe[incompatible-call]
|
|
39
16
|
ws.send(...args);
|
|
40
17
|
}
|
|
41
18
|
};
|
|
@@ -45,7 +22,6 @@ module.exports = function createWebsocketServer({ websocketServer }) {
|
|
|
45
22
|
return;
|
|
46
23
|
}
|
|
47
24
|
ws.on("error", (e) => {
|
|
48
|
-
// $FlowFixMe[incompatible-call]
|
|
49
25
|
websocketServer.onClientError && websocketServer.onClientError(client, e);
|
|
50
26
|
});
|
|
51
27
|
ws.on("close", () => {
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
|
-
// Debounces calls with the given delay, and queues the next call while the
|
|
15
|
-
// previous one hasn't completed so that no two calls can execute concurrently.
|
|
16
3
|
function debounceAsyncQueue(fn, delay) {
|
|
17
4
|
let timeout;
|
|
18
5
|
let waiting = false;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
1
|
"use strict";
|
|
12
2
|
|
|
13
3
|
const GraphNotFoundError = require("../IncrementalBundler/GraphNotFoundError");
|
|
@@ -59,21 +49,18 @@ function formatBundlingError(error) {
|
|
|
59
49
|
} else if (error instanceof ResourceNotFoundError) {
|
|
60
50
|
return {
|
|
61
51
|
type: "ResourceNotFoundError",
|
|
62
|
-
// $FlowFixMe[incompatible-return]
|
|
63
52
|
errors: [],
|
|
64
53
|
message: error.message,
|
|
65
54
|
};
|
|
66
55
|
} else if (error instanceof GraphNotFoundError) {
|
|
67
56
|
return {
|
|
68
57
|
type: "GraphNotFoundError",
|
|
69
|
-
// $FlowFixMe[incompatible-return]
|
|
70
58
|
errors: [],
|
|
71
59
|
message: error.message,
|
|
72
60
|
};
|
|
73
61
|
} else if (error instanceof RevisionNotFoundError) {
|
|
74
62
|
return {
|
|
75
63
|
type: "RevisionNotFoundError",
|
|
76
|
-
// $FlowFixMe[incompatible-return]
|
|
77
64
|
errors: [],
|
|
78
65
|
message: error.message,
|
|
79
66
|
};
|
|
@@ -85,7 +72,6 @@ function formatBundlingError(error) {
|
|
|
85
72
|
let codeFrame = "";
|
|
86
73
|
try {
|
|
87
74
|
codeFrame = codeFrameColumns(
|
|
88
|
-
// If the error was thrown in a node.js builtin module, this call will fail and mask the real error.
|
|
89
75
|
fs.readFileSync(fileName, "utf8"),
|
|
90
76
|
{
|
|
91
77
|
start: {
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
var _CountingSet = _interopRequireDefault(require("./CountingSet"));
|
package/src/lib/getGraphId.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
const canonicalize = require("metro-core/src/canonicalize");
|
package/src/lib/getMaxWorkers.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
1
|
"use strict";
|
|
13
2
|
|
|
14
3
|
const os = require("os");
|