metro 0.83.2 → 0.83.4
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 +25 -23
- package/src/Assets.js +50 -30
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.js +33 -22
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js +5 -1
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.js +9 -5
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.js +21 -17
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.js +5 -1
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js +5 -1
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +5 -1
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/js.js +33 -22
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +33 -22
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +5 -1
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.js +5 -1
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.flow.js +5 -1
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.js +9 -5
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.js +5 -1
- package/src/DeltaBundler/types.js +5 -1
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.js +5 -1
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.js +42 -30
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler.js +37 -22
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.js +33 -22
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.js +33 -22
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.js +5 -1
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.js +5 -1
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.js +112 -40
- package/src/Server.js.flow +110 -47
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.js +5 -1
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.js +5 -1
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.js +5 -1
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.flow.js +38 -27
- package/src/index.flow.js.flow +25 -20
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +5 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +5 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +33 -22
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js +5 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.js +10 -3
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.js +5 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +39 -28
- package/src/lib/TerminalReporter.js.flow +15 -15
- package/src/lib/contextModule.js +5 -1
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.js +28 -21
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.js +14 -3
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +5 -1
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.js +5 -1
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.js +5 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.js +44 -23
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/logToConsole.js +5 -1
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +33 -22
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.js +28 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.js +5 -1
- package/src/lib/reporting.js +5 -1
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/transformHelpers.js +16 -10
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.js +56 -43
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.js +64 -39
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.js +45 -32
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.js +5 -1
- package/src/node-haste/PackageCache.js +5 -1
- package/src/node-haste/lib/AssetPaths.js +7 -3
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +11 -7
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.js +5 -1
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.js +5 -1
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/util.js +5 -1
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.js +5 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +5 -1
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.flow.js +5 -1
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.js +7 -3
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/writeFile.js +13 -4
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/Bundler.d.ts +0 -39
- package/src/DeltaBundler/Graph.d.ts +0 -40
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
- package/src/DeltaBundler/Worker.d.ts +0 -45
- package/src/DeltaBundler/types.d.ts +0 -166
- package/src/DeltaBundler.d.ts +0 -58
- package/src/IncrementalBundler.d.ts +0 -98
- package/src/ModuleGraph/test-helpers.js +0 -75
- package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
- package/src/Server/MultipartResponse.d.ts +0 -31
- package/src/Server/symbolicate.d.ts +0 -31
- package/src/Server.d.ts +0 -118
- package/src/index.d.ts +0 -193
- package/src/lib/CountingSet.d.ts +0 -48
- package/src/lib/TerminalReporter.d.ts +0 -27
- package/src/lib/contextModule.d.ts +0 -22
- package/src/lib/getGraphId.d.ts +0 -11
- package/src/lib/reporting.d.ts +0 -144
- package/src/node-haste/DependencyGraph.d.ts +0 -62
- package/src/shared/output/bundle.d.ts +0 -35
- package/src/shared/types.d.ts +0 -130
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
declare var __METRO_GLOBAL_PREFIX__: string;
|
|
14
|
-
declare var __DOWNLOAD_AND_EXEC_FOR_TESTS__: (path: string) => Promise<
|
|
14
|
+
declare var __DOWNLOAD_AND_EXEC_FOR_TESTS__: (path: string) => Promise<unknown>;
|
|
15
15
|
|
|
16
16
|
const key = `${global.__METRO_GLOBAL_PREFIX__ ?? ''}__loadBundleAsync`;
|
|
17
17
|
|
|
@@ -14,11 +14,11 @@ import {copyContextToObject} from './utils';
|
|
|
14
14
|
|
|
15
15
|
declare var require: RequireWithContext;
|
|
16
16
|
|
|
17
|
-
function main():
|
|
17
|
+
function main(): unknown {
|
|
18
18
|
return copyContextToObject(
|
|
19
19
|
// $FlowFixMe[underconstrained-implicit-instantiation]
|
|
20
20
|
require.context('./subdir', undefined, undefined, 'sync'),
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
module.exports =
|
|
24
|
+
module.exports = main() as unknown;
|
|
@@ -33,7 +33,7 @@ export function copyContextToObject<T>(ctx: ContextModule<T>): {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function awaitProperties<T>(
|
|
36
|
-
obj:
|
|
36
|
+
obj: Readonly<{[key: string]: Promise<T>}>,
|
|
37
37
|
): Promise<{[key: string]: T}> {
|
|
38
38
|
const result: {[string]: T} = {};
|
|
39
39
|
return Promise.all(
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var _vm = _interopRequireDefault(require("vm"));
|
|
4
4
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
5
|
+
return e && e.__esModule
|
|
6
|
+
? e
|
|
7
|
+
: {
|
|
8
|
+
default: e,
|
|
9
|
+
};
|
|
6
10
|
}
|
|
7
11
|
module.exports = function execBundle(code, context = {}) {
|
|
8
12
|
if (_vm.default.isContext(context)) {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import vm from 'vm';
|
|
13
13
|
|
|
14
|
-
module.exports = function execBundle(code: string, context: any = {}):
|
|
14
|
+
module.exports = function execBundle(code: string, context: any = {}): unknown {
|
|
15
15
|
if (vm.isContext(context)) {
|
|
16
16
|
return vm.runInContext(code, context);
|
|
17
17
|
}
|
|
@@ -5,8 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
8
|
+
var _timers = require("timers");
|
|
8
9
|
function _interopRequireDefault(e) {
|
|
9
|
-
return e && e.__esModule
|
|
10
|
+
return e && e.__esModule
|
|
11
|
+
? e
|
|
12
|
+
: {
|
|
13
|
+
default: e,
|
|
14
|
+
};
|
|
10
15
|
}
|
|
11
16
|
class BatchProcessor {
|
|
12
17
|
constructor(options, processBatch) {
|
|
@@ -50,12 +55,14 @@ class BatchProcessor {
|
|
|
50
55
|
}
|
|
51
56
|
_processQueueOnceReady() {
|
|
52
57
|
if (this._queue.length >= this._options.maximumItems) {
|
|
53
|
-
|
|
58
|
+
if (this._timeoutHandle != null) {
|
|
59
|
+
(0, _timers.clearTimeout)(this._timeoutHandle);
|
|
60
|
+
}
|
|
54
61
|
process.nextTick(() => this._processQueue());
|
|
55
62
|
return;
|
|
56
63
|
}
|
|
57
64
|
if (this._timeoutHandle == null) {
|
|
58
|
-
this._timeoutHandle = setTimeout(
|
|
65
|
+
this._timeoutHandle = (0, _timers.setTimeout)(
|
|
59
66
|
() => this._processQueue(),
|
|
60
67
|
this._options.maximumDelayMs,
|
|
61
68
|
);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import invariant from 'invariant';
|
|
13
|
+
import {clearTimeout, setTimeout} from 'timers';
|
|
13
14
|
|
|
14
15
|
type ProcessBatch<TItem, TResult> = (
|
|
15
16
|
batch: Array<TItem>,
|
|
@@ -24,8 +25,8 @@ type BatchProcessorOptions = {
|
|
|
24
25
|
|
|
25
26
|
type QueueItem<TItem, TResult> = {
|
|
26
27
|
item: TItem,
|
|
27
|
-
reject: (error:
|
|
28
|
-
resolve: (result: TResult) =>
|
|
28
|
+
reject: (error: unknown) => unknown,
|
|
29
|
+
resolve: (result: TResult) => unknown,
|
|
29
30
|
...
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -41,7 +42,7 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
41
42
|
_options: BatchProcessorOptions;
|
|
42
43
|
_processBatch: ProcessBatch<TItem, TResult>;
|
|
43
44
|
_queue: Array<QueueItem<TItem, TResult>>;
|
|
44
|
-
_timeoutHandle: ?
|
|
45
|
+
_timeoutHandle: ?ReturnType<typeof setTimeout>;
|
|
45
46
|
|
|
46
47
|
constructor(
|
|
47
48
|
options: BatchProcessorOptions,
|
|
@@ -70,7 +71,7 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
70
71
|
this._onBatchFinished();
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error:
|
|
74
|
+
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: unknown): void {
|
|
74
75
|
for (let i = 0; i < jobs.length; ++i) {
|
|
75
76
|
jobs[i].reject(error);
|
|
76
77
|
}
|
|
@@ -94,7 +95,9 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
94
95
|
|
|
95
96
|
_processQueueOnceReady(): void {
|
|
96
97
|
if (this._queue.length >= this._options.maximumItems) {
|
|
97
|
-
|
|
98
|
+
if (this._timeoutHandle != null) {
|
|
99
|
+
clearTimeout(this._timeoutHandle);
|
|
100
|
+
}
|
|
98
101
|
process.nextTick(() => this._processQueue());
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
@@ -109,8 +112,8 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
109
112
|
queue(item: TItem): Promise<TResult> {
|
|
110
113
|
return new Promise(
|
|
111
114
|
(
|
|
112
|
-
resolve: (result: TResult) =>
|
|
113
|
-
reject: (error:
|
|
115
|
+
resolve: (result: TResult) => unknown,
|
|
116
|
+
reject: (error: unknown) => unknown,
|
|
114
117
|
) => {
|
|
115
118
|
this._queue.push({item, resolve, reject});
|
|
116
119
|
this._processQueueOnceReady();
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
13
13
|
has(item: T): boolean;
|
|
14
|
-
@@iterator(): Iterator<T>;
|
|
15
14
|
+size: number;
|
|
16
15
|
count(item: T): number;
|
|
17
16
|
forEach<ThisT>(
|
|
@@ -20,7 +19,7 @@ export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
|
20
19
|
value: T,
|
|
21
20
|
key: T,
|
|
22
21
|
set: ReadOnlyCountingSet<T>,
|
|
23
|
-
) =>
|
|
22
|
+
) => unknown,
|
|
24
23
|
|
|
25
24
|
// NOTE: Should be optional, but Flow seems happy to infer undefined here
|
|
26
25
|
// which is what we want.
|
|
@@ -88,6 +87,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
|
88
87
|
|
|
89
88
|
/*::
|
|
90
89
|
// For Flow's benefit
|
|
90
|
+
// $FlowFixMe[duplicate-class-member]
|
|
91
91
|
@@iterator(): Iterator<T> {
|
|
92
92
|
return this.values();
|
|
93
93
|
}
|
|
@@ -108,7 +108,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
forEach<ThisT>(
|
|
111
|
-
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) =>
|
|
111
|
+
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => unknown,
|
|
112
112
|
thisArg: ThisT,
|
|
113
113
|
): void {
|
|
114
114
|
for (const item of this) {
|
|
@@ -121,7 +121,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
|
121
121
|
// extend to custom collection classes. Instead let's assume values are
|
|
122
122
|
// sortable ( = strings) and make this look like an array with some stable
|
|
123
123
|
// order.
|
|
124
|
-
toJSON():
|
|
124
|
+
toJSON(): unknown {
|
|
125
125
|
return [...this].sort();
|
|
126
126
|
}
|
|
127
127
|
}
|
package/src/lib/JsonReporter.js
CHANGED
|
@@ -9,15 +9,17 @@ class JsonReporter {
|
|
|
9
9
|
this._stream = stream;
|
|
10
10
|
}
|
|
11
11
|
update(event) {
|
|
12
|
+
let eventToWrite = event;
|
|
12
13
|
if (event.error instanceof Error) {
|
|
13
14
|
const { message, stack } = event.error;
|
|
14
|
-
|
|
15
|
+
eventToWrite = {
|
|
16
|
+
...eventToWrite,
|
|
15
17
|
error: serializeError(event.error),
|
|
16
18
|
message,
|
|
17
19
|
stack,
|
|
18
|
-
}
|
|
20
|
+
};
|
|
19
21
|
}
|
|
20
|
-
this._stream.write(JSON.stringify(
|
|
22
|
+
this._stream.write(JSON.stringify(eventToWrite) + "\n");
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
exports.default = JsonReporter;
|
|
@@ -4,7 +4,7 @@
|
|
|
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.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
@@ -14,23 +14,24 @@ import type {Writable} from 'stream';
|
|
|
14
14
|
export type SerializedError = {
|
|
15
15
|
message: string,
|
|
16
16
|
stack: string,
|
|
17
|
-
errors?:
|
|
17
|
+
errors?: ReadonlyArray<SerializedError>,
|
|
18
18
|
cause?: SerializedError,
|
|
19
19
|
...
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type SerializedEvent<TEvent: {[string]:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
export type SerializedEvent<TEvent: {+[string]: unknown, ...}> =
|
|
23
|
+
TEvent extends {
|
|
24
|
+
error: Error,
|
|
25
|
+
...
|
|
26
|
+
}
|
|
27
|
+
? {
|
|
28
|
+
...Omit<TEvent, 'error'>,
|
|
29
|
+
error: SerializedError,
|
|
30
|
+
...
|
|
31
|
+
}
|
|
32
|
+
: TEvent;
|
|
32
33
|
|
|
33
|
-
export default class JsonReporter<TEvent: {[string]:
|
|
34
|
+
export default class JsonReporter<TEvent: {+[string]: unknown, ...}> {
|
|
34
35
|
_stream: Writable;
|
|
35
36
|
|
|
36
37
|
constructor(stream: Writable) {
|
|
@@ -42,19 +43,20 @@ export default class JsonReporter<TEvent: {[string]: any, ...}> {
|
|
|
42
43
|
* (Perhaps we should switch in favor of plain object?)
|
|
43
44
|
*/
|
|
44
45
|
update(event: TEvent): void {
|
|
46
|
+
let eventToWrite = event;
|
|
45
47
|
if (event.error instanceof Error) {
|
|
46
48
|
const {message, stack} = event.error;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
eventToWrite = {
|
|
50
|
+
...eventToWrite,
|
|
49
51
|
error: serializeError(event.error),
|
|
50
52
|
// TODO: Preexisting issue - this writes message, stack, etc. as
|
|
51
53
|
// top-level siblings of event.error (which was serialized to {}), whereas it was presumably
|
|
52
54
|
// intended to nest them _under_ error. Fix this in a breaking change.
|
|
53
55
|
message,
|
|
54
56
|
stack,
|
|
55
|
-
}
|
|
57
|
+
};
|
|
56
58
|
}
|
|
57
|
-
this._stream.write(JSON.stringify(
|
|
59
|
+
this._stream.write(JSON.stringify(eventToWrite) + '\n');
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
|
|
@@ -8,7 +8,11 @@ var _magicNumber = _interopRequireDefault(
|
|
|
8
8
|
require("../shared/output/RamBundle/magic-number"),
|
|
9
9
|
);
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
11
|
+
return e && e.__esModule
|
|
12
|
+
? e
|
|
13
|
+
: {
|
|
14
|
+
default: e,
|
|
15
|
+
};
|
|
12
16
|
}
|
|
13
17
|
const SIZEOF_UINT32 = 4;
|
|
14
18
|
const HEADER_SIZE = 3;
|
|
@@ -10,31 +10,42 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
|
11
11
|
var _metroCore = require("metro-core");
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
function
|
|
14
|
-
if ("function"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
31
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
32
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
13
|
+
function _interopRequireWildcard(e, t) {
|
|
14
|
+
if ("function" == typeof WeakMap)
|
|
15
|
+
var r = new WeakMap(),
|
|
16
|
+
n = new WeakMap();
|
|
17
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
18
|
+
if (!t && e && e.__esModule) return e;
|
|
19
|
+
var o,
|
|
20
|
+
i,
|
|
21
|
+
f = {
|
|
22
|
+
__proto__: null,
|
|
23
|
+
default: e,
|
|
24
|
+
};
|
|
25
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
26
|
+
return f;
|
|
27
|
+
if ((o = t ? n : r)) {
|
|
28
|
+
if (o.has(e)) return o.get(e);
|
|
29
|
+
o.set(e, f);
|
|
33
30
|
}
|
|
34
|
-
|
|
31
|
+
for (const t in e)
|
|
32
|
+
"default" !== t &&
|
|
33
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
34
|
+
((i =
|
|
35
|
+
(o = Object.defineProperty) &&
|
|
36
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
37
|
+
(i.get || i.set)
|
|
38
|
+
? o(f, t, i)
|
|
39
|
+
: (f[t] = e[t]));
|
|
40
|
+
return f;
|
|
41
|
+
})(e, t);
|
|
35
42
|
}
|
|
36
43
|
function _interopRequireDefault(e) {
|
|
37
|
-
return e && e.__esModule
|
|
44
|
+
return e && e.__esModule
|
|
45
|
+
? e
|
|
46
|
+
: {
|
|
47
|
+
default: e,
|
|
48
|
+
};
|
|
38
49
|
}
|
|
39
50
|
const DARK_BLOCK_CHAR = "\u2593";
|
|
40
51
|
const LIGHT_BLOCK_CHAR = "\u2591";
|
|
@@ -60,9 +71,6 @@ class TerminalReporter {
|
|
|
60
71
|
},
|
|
61
72
|
phase,
|
|
62
73
|
) {
|
|
63
|
-
if (isPrefetch) {
|
|
64
|
-
bundleType = "PREBUNDLE";
|
|
65
|
-
}
|
|
66
74
|
const localPath = _path.default.relative(".", entryFile);
|
|
67
75
|
const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
|
|
68
76
|
const bundleTypeColor =
|
|
@@ -81,7 +89,9 @@ class TerminalReporter {
|
|
|
81
89
|
_chalk.default.dim(`(${transformedFileCount}/${totalFileCount})`)
|
|
82
90
|
: "";
|
|
83
91
|
return (
|
|
84
|
-
bundleTypeColor.inverse.bold(
|
|
92
|
+
bundleTypeColor.inverse.bold(
|
|
93
|
+
` ${isPrefetch === true ? "PREBUNDLE" : bundleType.toUpperCase()} `,
|
|
94
|
+
) +
|
|
85
95
|
_chalk.default.reset.dim(` ${_path.default.dirname(localPath)}/`) +
|
|
86
96
|
_chalk.default.bold(_path.default.basename(localPath)) +
|
|
87
97
|
" " +
|
|
@@ -261,8 +271,9 @@ class TerminalReporter {
|
|
|
261
271
|
message = error.stack;
|
|
262
272
|
}
|
|
263
273
|
}
|
|
264
|
-
|
|
265
|
-
|
|
274
|
+
const filename = error.filename;
|
|
275
|
+
if (filename?.length && !message.includes(filename)) {
|
|
276
|
+
message += ` [${filename}]`;
|
|
266
277
|
}
|
|
267
278
|
if (error.snippet != null) {
|
|
268
279
|
message += "\n" + error.snippet;
|
|
@@ -4,7 +4,7 @@
|
|
|
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.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
@@ -16,6 +16,7 @@ import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
|
16
16
|
import logToConsole from './logToConsole';
|
|
17
17
|
import * as reporting from './reporting';
|
|
18
18
|
import chalk from 'chalk';
|
|
19
|
+
// $FlowFixMe[untyped-import] lodash.throttle
|
|
19
20
|
import throttle from 'lodash.throttle';
|
|
20
21
|
import {AmbiguousModuleResolutionError} from 'metro-core';
|
|
21
22
|
import path from 'path';
|
|
@@ -41,7 +42,7 @@ export type TerminalReportableEvent =
|
|
|
41
42
|
| {
|
|
42
43
|
type: 'unstable_server_log',
|
|
43
44
|
level: 'info' | 'warn' | 'error',
|
|
44
|
-
data: string | Array<
|
|
45
|
+
data: string | Array<unknown>,
|
|
45
46
|
...
|
|
46
47
|
}
|
|
47
48
|
| {
|
|
@@ -56,11 +57,11 @@ export type TerminalReportableEvent =
|
|
|
56
57
|
|
|
57
58
|
type BuildPhase = 'in_progress' | 'done' | 'failed';
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
interface SnippetError extends Error {
|
|
61
|
+
code?: string;
|
|
62
|
+
filename?: string;
|
|
63
|
+
snippet?: string;
|
|
64
|
+
}
|
|
64
65
|
|
|
65
66
|
const DARK_BLOCK_CHAR = '\u2593';
|
|
66
67
|
const LIGHT_BLOCK_CHAR = '\u2591';
|
|
@@ -117,10 +118,6 @@ export default class TerminalReporter {
|
|
|
117
118
|
}: BundleProgress,
|
|
118
119
|
phase: BuildPhase,
|
|
119
120
|
): string {
|
|
120
|
-
if (isPrefetch) {
|
|
121
|
-
bundleType = 'PREBUNDLE';
|
|
122
|
-
}
|
|
123
|
-
|
|
124
121
|
const localPath = path.relative('.', entryFile);
|
|
125
122
|
const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
|
|
126
123
|
const bundleTypeColor =
|
|
@@ -140,7 +137,9 @@ export default class TerminalReporter {
|
|
|
140
137
|
: '';
|
|
141
138
|
|
|
142
139
|
return (
|
|
143
|
-
bundleTypeColor.inverse.bold(
|
|
140
|
+
bundleTypeColor.inverse.bold(
|
|
141
|
+
` ${isPrefetch === true ? 'PREBUNDLE' : bundleType.toUpperCase()} `,
|
|
142
|
+
) +
|
|
144
143
|
chalk.reset.dim(` ${path.dirname(localPath)}/`) +
|
|
145
144
|
chalk.bold(path.basename(localPath)) +
|
|
146
145
|
' ' +
|
|
@@ -273,6 +272,7 @@ export default class TerminalReporter {
|
|
|
273
272
|
case 'dep_graph_loading':
|
|
274
273
|
const color = event.hasReducedPerformance ? chalk.red : chalk.blue;
|
|
275
274
|
// eslint-disable-next-line import/no-commonjs
|
|
275
|
+
// $FlowFixMe[untyped-import] package.json
|
|
276
276
|
const version = 'v' + require('../../package.json').version;
|
|
277
277
|
this.terminal.log(
|
|
278
278
|
color.bold(
|
|
@@ -331,9 +331,9 @@ export default class TerminalReporter {
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
message += ` [${
|
|
334
|
+
const filename = error.filename;
|
|
335
|
+
if (filename?.length && !message.includes(filename)) {
|
|
336
|
+
message += ` [${filename}]`;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
if (error.snippet != null) {
|
package/src/lib/contextModule.js
CHANGED
|
@@ -9,7 +9,11 @@ var _crypto = _interopRequireDefault(require("crypto"));
|
|
|
9
9
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
function _interopRequireDefault(e) {
|
|
12
|
-
return e && e.__esModule
|
|
12
|
+
return e && e.__esModule
|
|
13
|
+
? e
|
|
14
|
+
: {
|
|
15
|
+
default: e,
|
|
16
|
+
};
|
|
13
17
|
}
|
|
14
18
|
function toHash(value) {
|
|
15
19
|
return _crypto.default.createHash("sha1").update(value).digest("hex");
|
|
@@ -18,7 +18,7 @@ import crypto from 'crypto';
|
|
|
18
18
|
import nullthrows from 'nullthrows';
|
|
19
19
|
import path from 'path';
|
|
20
20
|
|
|
21
|
-
export type RequireContext =
|
|
21
|
+
export type RequireContext = Readonly<{
|
|
22
22
|
/* Should search for files recursively. Optional, default `true` when `require.context` is used */
|
|
23
23
|
recursive: boolean,
|
|
24
24
|
/* Filename filter pattern for use in `require.context`. Optional, default `.*` (any file) when `require.context` is used */
|