metro 0.84.3 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -18
- package/src/Assets.js +23 -14
- package/src/Assets.js.flow +51 -38
- package/src/Bundler.d.ts +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +1 -16
- package/src/DeltaBundler/DeltaCalculator.js.flow +1 -1
- package/src/DeltaBundler/Graph.d.ts +1 -102
- package/src/DeltaBundler/Graph.js.flow +7 -7
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAssets.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +5 -5
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +3 -3
- package/src/DeltaBundler/Transformer.d.ts +2 -10
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +2 -47
- package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -3
- package/src/DeltaBundler/types.js.flow +10 -10
- package/src/DeltaBundler.d.ts +1 -5
- package/src/HmrServer.d.ts +2 -45
- package/src/HmrServer.js.flow +10 -10
- package/src/IncrementalBundler.d.ts +1 -9
- package/src/IncrementalBundler.js.flow +9 -6
- package/src/ModuleGraph/worker/collectDependencies.d.ts +1 -2
- package/src/ModuleGraph/worker/collectDependencies.js +52 -0
- package/src/ModuleGraph/worker/collectDependencies.js.flow +67 -0
- package/src/Server/symbolicate.js.flow +13 -13
- package/src/Server.d.ts +3 -176
- package/src/Server.js +42 -5
- package/src/Server.js.flow +70 -28
- package/src/index.flow.js +2 -2
- package/src/index.flow.js.flow +2 -2
- package/src/lib/BatchProcessor.d.ts +1 -21
- package/src/lib/CountingSet.js.flow +1 -1
- package/src/lib/JsonReporter.d.ts +1 -2
- package/src/lib/JsonReporter.js.flow +4 -2
- package/src/lib/RamBundleParser.d.ts +1 -6
- package/src/lib/TerminalReporter.d.ts +2 -78
- package/src/lib/TerminalReporter.js +39 -41
- package/src/lib/TerminalReporter.js.flow +52 -33
- package/src/lib/bundleToString.js.flow +2 -2
- package/src/lib/createWebsocketServer.js.flow +4 -4
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getPreludeCode.js.flow +5 -5
- package/src/lib/logToConsole.js +8 -7
- package/src/lib/logToConsole.js.flow +7 -7
- package/src/lib/reporting.js +16 -7
- package/src/lib/reporting.js.flow +16 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +1 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +1 -1
- package/src/node-haste/DependencyGraph/createFileMap.js +0 -2
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +0 -2
- package/src/node-haste/DependencyGraph.d.ts +1 -30
- package/src/node-haste/DependencyGraph.js.flow +2 -2
- package/src/shared/output/RamBundle/util.js.flow +4 -2
- package/src/shared/types.js.flow +31 -31
|
@@ -14,9 +14,12 @@ import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
|
14
14
|
import type {CustomResolverOptions} from 'metro-resolver';
|
|
15
15
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import tty from 'tty';
|
|
18
18
|
import util from 'util';
|
|
19
19
|
|
|
20
|
+
const supportsColor = (): boolean =>
|
|
21
|
+
process.stdout instanceof tty.WriteStream && process.stdout.hasColors();
|
|
22
|
+
|
|
20
23
|
export type BundleDetails = {
|
|
21
24
|
bundleType: string,
|
|
22
25
|
customResolverOptions: CustomResolverOptions,
|
|
@@ -190,7 +193,11 @@ export function logWarning(
|
|
|
190
193
|
...args: Array<unknown>
|
|
191
194
|
): void {
|
|
192
195
|
const str = util.format(format, ...args);
|
|
193
|
-
terminal.log(
|
|
196
|
+
terminal.log(
|
|
197
|
+
'%s %s',
|
|
198
|
+
util.styleText(['yellow', 'inverse', 'bold'], ' WARN '),
|
|
199
|
+
str,
|
|
200
|
+
);
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
/**
|
|
@@ -203,13 +210,13 @@ export function logError(
|
|
|
203
210
|
): void {
|
|
204
211
|
terminal.log(
|
|
205
212
|
'%s %s',
|
|
206
|
-
|
|
213
|
+
util.styleText(['red', 'inverse', 'bold'], ' ERROR '),
|
|
207
214
|
// Syntax errors may have colors applied for displaying code frames
|
|
208
215
|
// in various places outside of where Metro is currently running.
|
|
209
216
|
// If the current terminal does not support color, we'll strip the colors
|
|
210
217
|
// here.
|
|
211
218
|
util.format(
|
|
212
|
-
|
|
219
|
+
supportsColor() ? format : util.stripVTControlCharacters(format),
|
|
213
220
|
...args,
|
|
214
221
|
),
|
|
215
222
|
);
|
|
@@ -224,7 +231,11 @@ export function logInfo(
|
|
|
224
231
|
...args: Array<unknown>
|
|
225
232
|
): void {
|
|
226
233
|
const str = util.format(format, ...args);
|
|
227
|
-
terminal.log(
|
|
234
|
+
terminal.log(
|
|
235
|
+
'%s %s',
|
|
236
|
+
util.styleText(['cyan', 'inverse', 'bold'], ' INFO '),
|
|
237
|
+
str,
|
|
238
|
+
);
|
|
228
239
|
}
|
|
229
240
|
|
|
230
241
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<2948a6737474a8f5bd55952246f500d3>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js
|
|
@@ -24,9 +24,7 @@ import type {ResolverInputOptions} from '../../shared/types';
|
|
|
24
24
|
import type {
|
|
25
25
|
CustomResolver,
|
|
26
26
|
DoesFileExist,
|
|
27
|
-
FileCandidates,
|
|
28
27
|
FileSystemLookup,
|
|
29
|
-
Resolution,
|
|
30
28
|
ResolveAsset,
|
|
31
29
|
} from 'metro-resolver';
|
|
32
30
|
import type {PackageForModule, PackageJson} from 'metro-resolver/private/types';
|
|
@@ -68,11 +66,7 @@ type Options = Readonly<{
|
|
|
68
66
|
unstable_incrementalResolution: boolean;
|
|
69
67
|
}>;
|
|
70
68
|
export declare class ModuleResolver {
|
|
71
|
-
_options: Options;
|
|
72
|
-
_projectRootFakeModulePath: string;
|
|
73
|
-
_cachedEmptyModule: null | undefined | BundlerResolution;
|
|
74
69
|
constructor(options: Options);
|
|
75
|
-
_getEmptyModule(): BundlerResolution;
|
|
76
70
|
resolveDependency(
|
|
77
71
|
originModulePath: string,
|
|
78
72
|
dependency: TransformResultDependency,
|
|
@@ -80,12 +74,6 @@ export declare class ModuleResolver {
|
|
|
80
74
|
platform: string | null,
|
|
81
75
|
resolverOptions: ResolverInputOptions,
|
|
82
76
|
): BundlerResolution;
|
|
83
|
-
/**
|
|
84
|
-
* TODO: Return Resolution instead of coercing to BundlerResolution here
|
|
85
|
-
*/
|
|
86
|
-
_getFileResolvedModule(resolution: Resolution): BundlerResolution;
|
|
87
|
-
_logWarning: (message: string) => void;
|
|
88
|
-
_removeRoot(candidates: FileCandidates): FileCandidates;
|
|
89
77
|
}
|
|
90
78
|
export declare class UnableToResolveError extends Error {
|
|
91
79
|
/**
|
|
@@ -291,7 +291,7 @@ export class UnableToResolveError extends Error {
|
|
|
291
291
|
/**
|
|
292
292
|
* Fixed type field in common with other Metro build errors.
|
|
293
293
|
*/
|
|
294
|
-
|
|
294
|
+
readonly type: 'UnableToResolveError' = 'UnableToResolveError';
|
|
295
295
|
|
|
296
296
|
constructor(
|
|
297
297
|
originModulePath: string,
|
|
@@ -80,7 +80,6 @@ function createFileMap(config, options) {
|
|
|
80
80
|
dependencyPlugin = new _metroFileMap.DependencyPlugin({
|
|
81
81
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
82
82
|
computeDependencies: true,
|
|
83
|
-
rootDir: config.projectRoot,
|
|
84
83
|
});
|
|
85
84
|
plugins.push(dependencyPlugin);
|
|
86
85
|
}
|
|
@@ -115,7 +114,6 @@ function createFileMap(config, options) {
|
|
|
115
114
|
...config.watcher.additionalExts,
|
|
116
115
|
]),
|
|
117
116
|
),
|
|
118
|
-
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
119
117
|
healthCheck: config.watcher.healthCheck,
|
|
120
118
|
ignorePattern: getIgnorePattern(config),
|
|
121
119
|
maxWorkers: config.maxWorkers,
|
|
@@ -88,7 +88,6 @@ export default function createFileMap(
|
|
|
88
88
|
dependencyPlugin = new DependencyPlugin({
|
|
89
89
|
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
90
90
|
computeDependencies: true,
|
|
91
|
-
rootDir: config.projectRoot,
|
|
92
91
|
});
|
|
93
92
|
plugins.push(dependencyPlugin);
|
|
94
93
|
}
|
|
@@ -126,7 +125,6 @@ export default function createFileMap(
|
|
|
126
125
|
...config.watcher.additionalExts,
|
|
127
126
|
]),
|
|
128
127
|
),
|
|
129
|
-
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
130
128
|
healthCheck: config.watcher.healthCheck,
|
|
131
129
|
ignorePattern: getIgnorePattern(config),
|
|
132
130
|
maxWorkers: config.maxWorkers,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<1cc985f3869f7db49aca7daeca848b82>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/node-haste/DependencyGraph.js
|
|
@@ -21,32 +21,10 @@ import type {
|
|
|
21
21
|
} from '../DeltaBundler/types';
|
|
22
22
|
import type {ResolverInputOptions} from '../shared/types';
|
|
23
23
|
import type {ConfigT} from 'metro-config';
|
|
24
|
-
import type {
|
|
25
|
-
ChangeEvent,
|
|
26
|
-
FileSystem,
|
|
27
|
-
HasteMap,
|
|
28
|
-
HealthCheckResult,
|
|
29
|
-
WatcherStatus,
|
|
30
|
-
default as MetroFileMap,
|
|
31
|
-
} from 'metro-file-map';
|
|
32
24
|
|
|
33
|
-
import {ModuleResolver} from './DependencyGraph/ModuleResolution';
|
|
34
25
|
import EventEmitter from 'events';
|
|
35
26
|
|
|
36
27
|
declare class DependencyGraph extends EventEmitter {
|
|
37
|
-
_config: ConfigT;
|
|
38
|
-
_haste: MetroFileMap;
|
|
39
|
-
_fileSystem: FileSystem;
|
|
40
|
-
_hasteMap: HasteMap;
|
|
41
|
-
_moduleResolver: ModuleResolver;
|
|
42
|
-
_resolutionCache: Map<
|
|
43
|
-
string | symbol,
|
|
44
|
-
Map<
|
|
45
|
-
string | symbol,
|
|
46
|
-
Map<string | symbol, Map<string | symbol, BundlerResolution>>
|
|
47
|
-
>
|
|
48
|
-
>;
|
|
49
|
-
_initializedPromise: Promise<void>;
|
|
50
28
|
constructor(
|
|
51
29
|
config: ConfigT,
|
|
52
30
|
options?: {
|
|
@@ -54,14 +32,7 @@ declare class DependencyGraph extends EventEmitter {
|
|
|
54
32
|
readonly watch?: boolean;
|
|
55
33
|
},
|
|
56
34
|
);
|
|
57
|
-
_onWatcherHealthCheck(result: HealthCheckResult): void;
|
|
58
|
-
_onWatcherStatus(status: WatcherStatus): void;
|
|
59
35
|
ready(): Promise<void>;
|
|
60
|
-
_onHasteChange($$PARAM_0$$: ChangeEvent): void;
|
|
61
|
-
_createModuleResolver(): void;
|
|
62
|
-
_getClosestPackage(
|
|
63
|
-
absoluteModulePath: string,
|
|
64
|
-
): null | undefined | {packageJsonPath: string; packageRelativePath: string};
|
|
65
36
|
getAllFiles(): Array<string>;
|
|
66
37
|
/**
|
|
67
38
|
* Used when watcher.unstable_lazySha1 is true
|
|
@@ -88,8 +88,8 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
88
88
|
constructor(
|
|
89
89
|
config: ConfigT,
|
|
90
90
|
options?: {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
readonly hasReducedPerformance?: boolean,
|
|
92
|
+
readonly watch?: boolean,
|
|
93
93
|
},
|
|
94
94
|
) {
|
|
95
95
|
super();
|
|
@@ -135,8 +135,10 @@ function combineMaps(
|
|
|
135
135
|
return sections;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const joinModules = (
|
|
139
|
-
modules
|
|
138
|
+
const joinModules = (
|
|
139
|
+
modules: ReadonlyArray<{readonly code: string, ...}>,
|
|
140
|
+
): string =>
|
|
141
|
+
modules.map((m: {readonly code: string, ...}) => m.code).join('\n');
|
|
140
142
|
|
|
141
143
|
export {
|
|
142
144
|
combineSourceMaps,
|
package/src/shared/types.js.flow
CHANGED
|
@@ -47,24 +47,24 @@ export type ReadonlySourceLocation = Readonly<{
|
|
|
47
47
|
}>;
|
|
48
48
|
|
|
49
49
|
export type BundleOptions = {
|
|
50
|
-
|
|
50
|
+
readonly customResolverOptions: CustomResolverOptions,
|
|
51
51
|
customTransformOptions: CustomTransformOptions,
|
|
52
52
|
dev: boolean,
|
|
53
53
|
entryFile: string,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
readonly excludeSource: boolean,
|
|
55
|
+
readonly inlineSourceMap: boolean,
|
|
56
|
+
readonly lazy: boolean,
|
|
57
57
|
minify: boolean,
|
|
58
|
-
|
|
58
|
+
readonly modulesOnly: boolean,
|
|
59
59
|
onProgress: ?(doneCont: number, totalCount: number) => unknown,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
readonly platform: ?string,
|
|
61
|
+
readonly runModule: boolean,
|
|
62
|
+
readonly shallow: boolean,
|
|
63
63
|
sourceMapUrl: ?string,
|
|
64
64
|
sourceUrl: ?string,
|
|
65
65
|
createModuleIdFactory?: () => (path: string) => number,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
readonly unstable_transformProfile: TransformProfile,
|
|
67
|
+
readonly sourcePaths: SourcePathsMode,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
export type BuildOptions = Readonly<{
|
|
@@ -77,18 +77,18 @@ export type ResolverInputOptions = Readonly<{
|
|
|
77
77
|
}>;
|
|
78
78
|
|
|
79
79
|
export type SerializerOptions = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
readonly sourceMapUrl: ?string,
|
|
81
|
+
readonly sourceUrl: ?string,
|
|
82
|
+
readonly runModule: boolean,
|
|
83
|
+
readonly excludeSource: boolean,
|
|
84
|
+
readonly inlineSourceMap: boolean,
|
|
85
|
+
readonly modulesOnly: boolean,
|
|
86
|
+
readonly sourcePaths: SourcePathsMode,
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
export type GraphOptions = {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
readonly lazy: boolean,
|
|
91
|
+
readonly shallow: boolean,
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// Stricter representation of BundleOptions.
|
|
@@ -108,24 +108,24 @@ export type ModuleGroups = {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
export type ModuleTransportLike = {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
readonly code: string,
|
|
112
|
+
readonly id: number,
|
|
113
|
+
readonly map: ?MetroSourceMapOrMappings,
|
|
114
|
+
readonly name?: string,
|
|
115
|
+
readonly sourcePath: string,
|
|
116
116
|
...
|
|
117
117
|
};
|
|
118
118
|
export type ModuleTransportLikeStrict = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
readonly code: string,
|
|
120
|
+
readonly id: number,
|
|
121
|
+
readonly map: ?MetroSourceMapOrMappings,
|
|
122
|
+
readonly name?: string,
|
|
123
|
+
readonly sourcePath: string,
|
|
124
124
|
};
|
|
125
125
|
export type RamModuleTransport = {
|
|
126
126
|
...ModuleTransportLikeStrict,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
readonly source: string,
|
|
128
|
+
readonly type: string,
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
export type OutputOptions = {
|