metro 0.80.7 → 0.80.9
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 +15 -15
- package/src/DeltaBundler/Transformer.js +16 -2
- package/src/DeltaBundler/Transformer.js.flow +16 -2
- package/src/ModuleGraph/worker/JsFileWrapping.js +3 -2
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +4 -1
- package/src/Server.js.flow +1 -0
- package/src/lib/JsonReporter.js.flow +12 -0
- package/src/lib/TerminalReporter.js +0 -24
- package/src/lib/TerminalReporter.js.flow +1 -31
- package/src/lib/logToConsole.js.flow +1 -0
- package/src/lib/reporting.d.ts +3 -5
- package/src/lib/reporting.js.flow +3 -5
- package/src/node-haste/lib/AssetPaths.js +1 -1
- package/src/node-haste/lib/AssetPaths.js.flow +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.9",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"jest-worker": "^29.6.3",
|
|
35
35
|
"jsc-safe-url": "^0.2.2",
|
|
36
36
|
"lodash.throttle": "^4.1.1",
|
|
37
|
-
"metro-babel-transformer": "0.80.
|
|
38
|
-
"metro-cache": "0.80.
|
|
39
|
-
"metro-cache-key": "0.80.
|
|
40
|
-
"metro-config": "0.80.
|
|
41
|
-
"metro-core": "0.80.
|
|
42
|
-
"metro-file-map": "0.80.
|
|
43
|
-
"metro-resolver": "0.80.
|
|
44
|
-
"metro-runtime": "0.80.
|
|
45
|
-
"metro-source-map": "0.80.
|
|
46
|
-
"metro-symbolicate": "0.80.
|
|
47
|
-
"metro-transform-plugins": "0.80.
|
|
48
|
-
"metro-transform-worker": "0.80.
|
|
37
|
+
"metro-babel-transformer": "0.80.9",
|
|
38
|
+
"metro-cache": "0.80.9",
|
|
39
|
+
"metro-cache-key": "0.80.9",
|
|
40
|
+
"metro-config": "0.80.9",
|
|
41
|
+
"metro-core": "0.80.9",
|
|
42
|
+
"metro-file-map": "0.80.9",
|
|
43
|
+
"metro-resolver": "0.80.9",
|
|
44
|
+
"metro-runtime": "0.80.9",
|
|
45
|
+
"metro-source-map": "0.80.9",
|
|
46
|
+
"metro-symbolicate": "0.80.9",
|
|
47
|
+
"metro-transform-plugins": "0.80.9",
|
|
48
|
+
"metro-transform-worker": "0.80.9",
|
|
49
49
|
"mime-types": "^2.1.27",
|
|
50
50
|
"node-fetch": "^2.2.0",
|
|
51
51
|
"nullthrows": "^1.1.1",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"dedent": "^0.7.0",
|
|
67
67
|
"jest-snapshot": "^29.6.3",
|
|
68
68
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
69
|
-
"metro-babel-register": "0.80.
|
|
70
|
-
"metro-memory-fs": "0.80.
|
|
69
|
+
"metro-babel-register": "0.80.9",
|
|
70
|
+
"metro-memory-fs": "0.80.9",
|
|
71
71
|
"mock-req": "^0.2.0",
|
|
72
72
|
"mock-res": "^0.6.0",
|
|
73
73
|
"stack-trace": "^0.0.10"
|
|
@@ -88,7 +88,16 @@ class Transformer {
|
|
|
88
88
|
sha1 = this._getSha1(filePath);
|
|
89
89
|
}
|
|
90
90
|
let fullKey = Buffer.concat([partialKey, Buffer.from(sha1, "hex")]);
|
|
91
|
-
|
|
91
|
+
let result;
|
|
92
|
+
try {
|
|
93
|
+
result = await cache.get(fullKey);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
this._config.reporter.update({
|
|
96
|
+
type: "cache_read_error",
|
|
97
|
+
error,
|
|
98
|
+
});
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
92
101
|
const data = result
|
|
93
102
|
? {
|
|
94
103
|
result,
|
|
@@ -102,7 +111,12 @@ class Transformer {
|
|
|
102
111
|
if (sha1 !== data.sha1) {
|
|
103
112
|
fullKey = Buffer.concat([partialKey, Buffer.from(data.sha1, "hex")]);
|
|
104
113
|
}
|
|
105
|
-
|
|
114
|
+
cache.set(fullKey, data.result).catch((error) => {
|
|
115
|
+
this._config.reporter.update({
|
|
116
|
+
type: "cache_write_error",
|
|
117
|
+
error,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
106
120
|
return {
|
|
107
121
|
...data.result,
|
|
108
122
|
unstable_transformResultKey: fullKey.toString(),
|
|
@@ -131,7 +131,16 @@ class Transformer {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
let fullKey = Buffer.concat([partialKey, Buffer.from(sha1, 'hex')]);
|
|
134
|
-
|
|
134
|
+
let result;
|
|
135
|
+
try {
|
|
136
|
+
result = await cache.get(fullKey);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
this._config.reporter.update({
|
|
139
|
+
type: 'cache_read_error',
|
|
140
|
+
error,
|
|
141
|
+
});
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
135
144
|
|
|
136
145
|
// A valid result from the cache is used directly; otherwise we call into
|
|
137
146
|
// the transformer to computed the corresponding result.
|
|
@@ -154,7 +163,12 @@ class Transformer {
|
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
// Fire-and-forget cache set promise.
|
|
157
|
-
|
|
166
|
+
cache.set(fullKey, data.result).catch(error => {
|
|
167
|
+
this._config.reporter.update({
|
|
168
|
+
type: 'cache_write_error',
|
|
169
|
+
error,
|
|
170
|
+
});
|
|
171
|
+
});
|
|
158
172
|
|
|
159
173
|
return {
|
|
160
174
|
...data.result,
|
|
@@ -56,7 +56,8 @@ function wrapModule(
|
|
|
56
56
|
importDefaultName,
|
|
57
57
|
importAllName,
|
|
58
58
|
dependencyMapName,
|
|
59
|
-
globalPrefix
|
|
59
|
+
globalPrefix,
|
|
60
|
+
skipRequireRename
|
|
60
61
|
) {
|
|
61
62
|
const params = buildParameters(
|
|
62
63
|
importDefaultName,
|
|
@@ -66,7 +67,7 @@ function wrapModule(
|
|
|
66
67
|
const factory = functionFromProgram(fileAst.program, params);
|
|
67
68
|
const def = t.callExpression(t.identifier(`${globalPrefix}__d`), [factory]);
|
|
68
69
|
const ast = t.file(t.program([t.expressionStatement(def)]));
|
|
69
|
-
const requireName = renameRequires(ast);
|
|
70
|
+
const requireName = skipRequireRename ? "require" : renameRequires(ast);
|
|
70
71
|
return {
|
|
71
72
|
ast,
|
|
72
73
|
requireName,
|
|
@@ -32,6 +32,7 @@ function wrapModule(
|
|
|
32
32
|
importAllName: string,
|
|
33
33
|
dependencyMapName: string,
|
|
34
34
|
globalPrefix: string,
|
|
35
|
+
skipRequireRename: boolean,
|
|
35
36
|
): {
|
|
36
37
|
ast: BabelNodeFile,
|
|
37
38
|
requireName: string,
|
|
@@ -45,7 +46,9 @@ function wrapModule(
|
|
|
45
46
|
const def = t.callExpression(t.identifier(`${globalPrefix}__d`), [factory]);
|
|
46
47
|
const ast = t.file(t.program([t.expressionStatement(def)]));
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
// `require` doesn't need to be scoped when Metro serializes to iife because the local function
|
|
50
|
+
// `require` will be used instead of the global one.
|
|
51
|
+
const requireName = skipRequireRename ? 'require' : renameRequires(ast);
|
|
49
52
|
|
|
50
53
|
return {ast, requireName};
|
|
51
54
|
}
|
package/src/Server.js.flow
CHANGED
|
@@ -465,6 +465,7 @@ class Server {
|
|
|
465
465
|
);
|
|
466
466
|
// Tell clients to cache this for 1 year.
|
|
467
467
|
// This is safe as the asset url contains a hash of the asset.
|
|
468
|
+
// $FlowFixMe[incompatible-type]
|
|
468
469
|
if (process.env.REACT_NATIVE_ENABLE_ASSET_CACHING === true) {
|
|
469
470
|
res.setHeader('Cache-Control', 'max-age=31536000');
|
|
470
471
|
}
|
|
@@ -13,6 +13,18 @@
|
|
|
13
13
|
|
|
14
14
|
import type {Writable} from 'stream';
|
|
15
15
|
|
|
16
|
+
export type SerializedEvent<TEvent: {[string]: any, ...}> = TEvent extends {
|
|
17
|
+
error: Error,
|
|
18
|
+
...
|
|
19
|
+
}
|
|
20
|
+
? {
|
|
21
|
+
...Omit<TEvent, 'error'>,
|
|
22
|
+
message: string,
|
|
23
|
+
stack: string,
|
|
24
|
+
...
|
|
25
|
+
}
|
|
26
|
+
: TEvent;
|
|
27
|
+
|
|
16
28
|
class JsonReporter<TEvent: {[string]: any, ...}> {
|
|
17
29
|
_stream: Writable;
|
|
18
30
|
|
|
@@ -6,8 +6,6 @@ const chalk = require("chalk");
|
|
|
6
6
|
const throttle = require("lodash.throttle");
|
|
7
7
|
const { AmbiguousModuleResolutionError } = require("metro-core");
|
|
8
8
|
const path = require("path");
|
|
9
|
-
const GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT =
|
|
10
|
-
"The global cache is now disabled because %s";
|
|
11
9
|
const DARK_BLOCK_CHAR = "\u2593";
|
|
12
10
|
const LIGHT_BLOCK_CHAR = "\u2591";
|
|
13
11
|
const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
|
|
@@ -61,25 +59,6 @@ class TerminalReporter {
|
|
|
61
59
|
"\n"
|
|
62
60
|
);
|
|
63
61
|
}
|
|
64
|
-
_logCacheDisabled(reason) {
|
|
65
|
-
const format = GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT;
|
|
66
|
-
switch (reason) {
|
|
67
|
-
case "too_many_errors":
|
|
68
|
-
reporting.logWarning(
|
|
69
|
-
this.terminal,
|
|
70
|
-
format,
|
|
71
|
-
"it has been failing too many times."
|
|
72
|
-
);
|
|
73
|
-
break;
|
|
74
|
-
case "too_many_misses":
|
|
75
|
-
reporting.logWarning(
|
|
76
|
-
this.terminal,
|
|
77
|
-
format,
|
|
78
|
-
"it has been missing too many consecutive keys."
|
|
79
|
-
);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
62
|
_logBundleBuildDone(buildID) {
|
|
84
63
|
const progress = this._activeBundles.get(buildID);
|
|
85
64
|
if (progress != null) {
|
|
@@ -163,9 +142,6 @@ class TerminalReporter {
|
|
|
163
142
|
case "bundling_error":
|
|
164
143
|
this._logBundlingError(event.error);
|
|
165
144
|
break;
|
|
166
|
-
case "global_cache_disabled":
|
|
167
|
-
this._logCacheDisabled(event.reason);
|
|
168
|
-
break;
|
|
169
145
|
case "resolver_warning":
|
|
170
146
|
this._logWarning(event.message);
|
|
171
147
|
break;
|
|
@@ -11,11 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
import type {
|
|
15
|
-
BundleDetails,
|
|
16
|
-
GlobalCacheDisabledReason,
|
|
17
|
-
ReportableEvent,
|
|
18
|
-
} from './reporting';
|
|
14
|
+
import type {BundleDetails, ReportableEvent} from './reporting';
|
|
19
15
|
import type {Terminal} from 'metro-core';
|
|
20
16
|
import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
21
17
|
|
|
@@ -53,9 +49,6 @@ type SnippetError = ErrnoError &
|
|
|
53
49
|
snippet?: string,
|
|
54
50
|
};
|
|
55
51
|
|
|
56
|
-
const GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT =
|
|
57
|
-
'The global cache is now disabled because %s';
|
|
58
|
-
|
|
59
52
|
const DARK_BLOCK_CHAR = '\u2593';
|
|
60
53
|
const LIGHT_BLOCK_CHAR = '\u2591';
|
|
61
54
|
const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
|
|
@@ -141,26 +134,6 @@ class TerminalReporter {
|
|
|
141
134
|
);
|
|
142
135
|
}
|
|
143
136
|
|
|
144
|
-
_logCacheDisabled(reason: GlobalCacheDisabledReason): void {
|
|
145
|
-
const format = GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT;
|
|
146
|
-
switch (reason) {
|
|
147
|
-
case 'too_many_errors':
|
|
148
|
-
reporting.logWarning(
|
|
149
|
-
this.terminal,
|
|
150
|
-
format,
|
|
151
|
-
'it has been failing too many times.',
|
|
152
|
-
);
|
|
153
|
-
break;
|
|
154
|
-
case 'too_many_misses':
|
|
155
|
-
reporting.logWarning(
|
|
156
|
-
this.terminal,
|
|
157
|
-
format,
|
|
158
|
-
'it has been missing too many consecutive keys.',
|
|
159
|
-
);
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
137
|
_logBundleBuildDone(buildID: string): void {
|
|
165
138
|
const progress = this._activeBundles.get(buildID);
|
|
166
139
|
if (progress != null) {
|
|
@@ -253,9 +226,6 @@ class TerminalReporter {
|
|
|
253
226
|
case 'bundling_error':
|
|
254
227
|
this._logBundlingError(event.error);
|
|
255
228
|
break;
|
|
256
|
-
case 'global_cache_disabled':
|
|
257
|
-
this._logCacheDisabled(event.reason);
|
|
258
|
-
break;
|
|
259
229
|
case 'resolver_warning':
|
|
260
230
|
this._logWarning(event.message);
|
|
261
231
|
break;
|
package/src/lib/reporting.d.ts
CHANGED
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
12
12
|
|
|
13
|
-
export type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';
|
|
14
|
-
|
|
15
13
|
export interface BundleDetails {
|
|
16
14
|
bundleType: string;
|
|
17
15
|
dev: boolean;
|
|
@@ -65,12 +63,12 @@ export type ReportableEvent =
|
|
|
65
63
|
totalFileCount: number;
|
|
66
64
|
}
|
|
67
65
|
| {
|
|
68
|
-
type: '
|
|
66
|
+
type: 'cache_read_error';
|
|
69
67
|
error: Error;
|
|
70
68
|
}
|
|
71
69
|
| {
|
|
72
|
-
type: '
|
|
73
|
-
|
|
70
|
+
type: 'cache_write_error';
|
|
71
|
+
error: Error;
|
|
74
72
|
}
|
|
75
73
|
| {type: 'transform_cache_reset'}
|
|
76
74
|
| {
|
|
@@ -20,8 +20,6 @@ const chalk = require('chalk');
|
|
|
20
20
|
const stripAnsi = require('strip-ansi');
|
|
21
21
|
const util = require('util');
|
|
22
22
|
|
|
23
|
-
export type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';
|
|
24
|
-
|
|
25
23
|
export type BundleDetails = {
|
|
26
24
|
bundleType: string,
|
|
27
25
|
customResolverOptions: CustomResolverOptions,
|
|
@@ -90,13 +88,13 @@ export type ReportableEvent =
|
|
|
90
88
|
...
|
|
91
89
|
}
|
|
92
90
|
| {
|
|
93
|
-
type: '
|
|
91
|
+
type: 'cache_read_error',
|
|
94
92
|
error: Error,
|
|
95
93
|
...
|
|
96
94
|
}
|
|
97
95
|
| {
|
|
98
|
-
type: '
|
|
99
|
-
|
|
96
|
+
type: 'cache_write_error',
|
|
97
|
+
error: Error,
|
|
100
98
|
...
|
|
101
99
|
}
|
|
102
100
|
| {type: 'transform_cache_reset', ...}
|
|
@@ -41,7 +41,7 @@ function tryParse(filePath, platforms) {
|
|
|
41
41
|
function parse(filePath, platforms) {
|
|
42
42
|
const result = tryParse(filePath, platforms);
|
|
43
43
|
if (result == null) {
|
|
44
|
-
throw new Error(
|
|
44
|
+
throw new Error(`invalid asset file path: ${filePath}`);
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
@@ -69,7 +69,7 @@ function tryParse(
|
|
|
69
69
|
function parse(filePath: string, platforms: $ReadOnlySet<string>): AssetPath {
|
|
70
70
|
const result = tryParse(filePath, platforms);
|
|
71
71
|
if (result == null) {
|
|
72
|
-
throw new Error(
|
|
72
|
+
throw new Error(`invalid asset file path: ${filePath}`);
|
|
73
73
|
}
|
|
74
74
|
return result;
|
|
75
75
|
}
|