metro 0.81.3 → 0.82.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 +16 -16
- package/src/Bundler.js +4 -9
- package/src/Bundler.js.flow +4 -11
- package/src/DeltaBundler/Transformer.js +5 -12
- package/src/DeltaBundler/Transformer.js.flow +7 -17
- package/src/Server.js +1 -1
- package/src/Server.js.flow +1 -1
- package/src/node-haste/DependencyGraph.d.ts +1 -1
- package/src/node-haste/DependencyGraph.js +7 -16
- package/src/node-haste/DependencyGraph.js.flow +7 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0",
|
|
4
4
|
"description": "🚇 The JavaScript bundler for React Native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "src/cli.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"chalk": "^4.0.0",
|
|
33
33
|
"ci-info": "^2.0.0",
|
|
34
34
|
"connect": "^3.6.5",
|
|
35
|
-
"debug": "^
|
|
35
|
+
"debug": "^4.4.0",
|
|
36
36
|
"error-stack-parser": "^2.0.6",
|
|
37
37
|
"flow-enums-runtime": "^0.0.6",
|
|
38
38
|
"graceful-fs": "^4.2.4",
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
"jest-worker": "^29.7.0",
|
|
43
43
|
"jsc-safe-url": "^0.2.2",
|
|
44
44
|
"lodash.throttle": "^4.1.1",
|
|
45
|
-
"metro-babel-transformer": "0.
|
|
46
|
-
"metro-cache": "0.
|
|
47
|
-
"metro-cache-key": "0.
|
|
48
|
-
"metro-config": "0.
|
|
49
|
-
"metro-core": "0.
|
|
50
|
-
"metro-file-map": "0.
|
|
51
|
-
"metro-resolver": "0.
|
|
52
|
-
"metro-runtime": "0.
|
|
53
|
-
"metro-source-map": "0.
|
|
54
|
-
"metro-symbolicate": "0.
|
|
55
|
-
"metro-transform-plugins": "0.
|
|
56
|
-
"metro-transform-worker": "0.
|
|
45
|
+
"metro-babel-transformer": "0.82.0",
|
|
46
|
+
"metro-cache": "0.82.0",
|
|
47
|
+
"metro-cache-key": "0.82.0",
|
|
48
|
+
"metro-config": "0.82.0",
|
|
49
|
+
"metro-core": "0.82.0",
|
|
50
|
+
"metro-file-map": "0.82.0",
|
|
51
|
+
"metro-resolver": "0.82.0",
|
|
52
|
+
"metro-runtime": "0.82.0",
|
|
53
|
+
"metro-source-map": "0.82.0",
|
|
54
|
+
"metro-symbolicate": "0.82.0",
|
|
55
|
+
"metro-transform-plugins": "0.82.0",
|
|
56
|
+
"metro-transform-worker": "0.82.0",
|
|
57
57
|
"mime-types": "^2.1.27",
|
|
58
58
|
"nullthrows": "^1.1.1",
|
|
59
59
|
"serialize-error": "^2.1.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"dedent": "^0.7.0",
|
|
72
72
|
"jest-snapshot": "^29.7.0",
|
|
73
73
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
74
|
-
"metro-babel-register": "0.
|
|
75
|
-
"metro-memory-fs": "0.
|
|
74
|
+
"metro-babel-register": "0.82.0",
|
|
75
|
+
"metro-memory-fs": "0.82.0",
|
|
76
76
|
"mock-req": "^0.2.0",
|
|
77
77
|
"mock-res": "^0.6.0",
|
|
78
78
|
"stack-trace": "^0.0.10"
|
package/src/Bundler.js
CHANGED
|
@@ -11,15 +11,10 @@ class Bundler {
|
|
|
11
11
|
config.reporter.update({
|
|
12
12
|
type: "transformer_load_started",
|
|
13
13
|
});
|
|
14
|
-
this._transformer = new Transformer(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
unstable_getOrComputeSha1: (filePath) =>
|
|
19
|
-
this._depGraph.unstable_getOrComputeSha1(filePath),
|
|
20
|
-
}
|
|
21
|
-
: (...args) => this._depGraph.getSha1(...args)
|
|
22
|
-
);
|
|
14
|
+
this._transformer = new Transformer(config, {
|
|
15
|
+
getOrComputeSha1: (filePath) =>
|
|
16
|
+
this._depGraph.getOrComputeSha1(filePath),
|
|
17
|
+
});
|
|
23
18
|
config.reporter.update({
|
|
24
19
|
type: "transformer_load_done",
|
|
25
20
|
});
|
package/src/Bundler.js.flow
CHANGED
|
@@ -36,17 +36,10 @@ class Bundler {
|
|
|
36
36
|
.ready()
|
|
37
37
|
.then(() => {
|
|
38
38
|
config.reporter.update({type: 'transformer_load_started'});
|
|
39
|
-
this._transformer = new Transformer(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// once lazy SHA1 is stable. This will be a breaking change.
|
|
44
|
-
{
|
|
45
|
-
unstable_getOrComputeSha1: filePath =>
|
|
46
|
-
this._depGraph.unstable_getOrComputeSha1(filePath),
|
|
47
|
-
}
|
|
48
|
-
: (...args) => this._depGraph.getSha1(...args),
|
|
49
|
-
);
|
|
39
|
+
this._transformer = new Transformer(config, {
|
|
40
|
+
getOrComputeSha1: filePath =>
|
|
41
|
+
this._depGraph.getOrComputeSha1(filePath),
|
|
42
|
+
});
|
|
50
43
|
config.reporter.update({type: 'transformer_load_done'});
|
|
51
44
|
})
|
|
52
45
|
.catch(error => {
|
|
@@ -11,14 +11,11 @@ const fs = require("fs");
|
|
|
11
11
|
const { Cache, stableHash } = require("metro-cache");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
class Transformer {
|
|
14
|
-
constructor(config,
|
|
14
|
+
constructor(config, opts) {
|
|
15
15
|
this._config = config;
|
|
16
16
|
this._config.watchFolders.forEach(verifyRootExists);
|
|
17
17
|
this._cache = new Cache(config.cacheStores);
|
|
18
|
-
this._getSha1 =
|
|
19
|
-
typeof getSha1FnOrOpts === "function"
|
|
20
|
-
? getSha1FnOrOpts
|
|
21
|
-
: getSha1FnOrOpts.unstable_getOrComputeSha1;
|
|
18
|
+
this._getSha1 = opts.getOrComputeSha1;
|
|
22
19
|
const {
|
|
23
20
|
getTransformOptions: _getTransformOptions,
|
|
24
21
|
transformVariants: _transformVariants,
|
|
@@ -95,13 +92,9 @@ class Transformer {
|
|
|
95
92
|
content = fileBuffer;
|
|
96
93
|
} else {
|
|
97
94
|
const result = await this._getSha1(filePath);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
sha1 = result.sha1;
|
|
102
|
-
if (result.content) {
|
|
103
|
-
content = result.content;
|
|
104
|
-
}
|
|
95
|
+
sha1 = result.sha1;
|
|
96
|
+
if (result.content) {
|
|
97
|
+
content = result.content;
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
100
|
let fullKey = Buffer.concat([partialKey, Buffer.from(sha1, "hex")]);
|
|
@@ -24,30 +24,24 @@ const fs = require('fs');
|
|
|
24
24
|
const {Cache, stableHash} = require('metro-cache');
|
|
25
25
|
const path = require('path');
|
|
26
26
|
|
|
27
|
-
type
|
|
28
|
-
type EagerSha1Fn = string => string;
|
|
27
|
+
type GetOrComputeSha1Fn = string => Promise<{content?: Buffer, sha1: string}>;
|
|
29
28
|
|
|
30
29
|
class Transformer {
|
|
31
30
|
_config: ConfigT;
|
|
32
31
|
_cache: Cache<TransformResult<>>;
|
|
33
32
|
_baseHash: string;
|
|
34
|
-
_getSha1:
|
|
33
|
+
_getSha1: GetOrComputeSha1Fn;
|
|
35
34
|
_workerFarm: WorkerFarm;
|
|
36
35
|
|
|
37
36
|
constructor(
|
|
38
37
|
config: ConfigT,
|
|
39
|
-
|
|
40
|
-
| $ReadOnly<{unstable_getOrComputeSha1: LazySha1Fn}>
|
|
41
|
-
| EagerSha1Fn,
|
|
38
|
+
opts: $ReadOnly<{getOrComputeSha1: GetOrComputeSha1Fn}>,
|
|
42
39
|
) {
|
|
43
40
|
this._config = config;
|
|
44
41
|
|
|
45
42
|
this._config.watchFolders.forEach(verifyRootExists);
|
|
46
43
|
this._cache = new Cache(config.cacheStores);
|
|
47
|
-
this._getSha1 =
|
|
48
|
-
typeof getSha1FnOrOpts === 'function'
|
|
49
|
-
? getSha1FnOrOpts
|
|
50
|
-
: getSha1FnOrOpts.unstable_getOrComputeSha1;
|
|
44
|
+
this._getSha1 = opts.getOrComputeSha1;
|
|
51
45
|
|
|
52
46
|
// Remove the transformer config params that we don't want to pass to the
|
|
53
47
|
// transformer. We should change the config object and move them away so we
|
|
@@ -147,13 +141,9 @@ class Transformer {
|
|
|
147
141
|
content = fileBuffer;
|
|
148
142
|
} else {
|
|
149
143
|
const result = await this._getSha1(filePath);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
sha1 = result.sha1;
|
|
154
|
-
if (result.content) {
|
|
155
|
-
content = result.content;
|
|
156
|
-
}
|
|
144
|
+
sha1 = result.sha1;
|
|
145
|
+
if (result.content) {
|
|
146
|
+
content = result.content;
|
|
157
147
|
}
|
|
158
148
|
}
|
|
159
149
|
|
package/src/Server.js
CHANGED
|
@@ -450,7 +450,7 @@ class Server {
|
|
|
450
450
|
const depGraph = await this._bundler.getBundler().getDependencyGraph();
|
|
451
451
|
const filePath = path.join(rootDir, relativePathname);
|
|
452
452
|
try {
|
|
453
|
-
depGraph.
|
|
453
|
+
await depGraph.getOrComputeSha1(filePath);
|
|
454
454
|
} catch {
|
|
455
455
|
res.writeHead(404);
|
|
456
456
|
res.end();
|
package/src/Server.js.flow
CHANGED
|
@@ -630,7 +630,7 @@ class Server {
|
|
|
630
630
|
const depGraph = await this._bundler.getBundler().getDependencyGraph();
|
|
631
631
|
const filePath = path.join(rootDir, relativePathname);
|
|
632
632
|
try {
|
|
633
|
-
depGraph.
|
|
633
|
+
await depGraph.getOrComputeSha1(filePath);
|
|
634
634
|
} catch {
|
|
635
635
|
res.writeHead(404);
|
|
636
636
|
res.end();
|
|
@@ -34,7 +34,7 @@ export default class DependencyGraph extends EventEmitter {
|
|
|
34
34
|
): Promise<DependencyGraph>;
|
|
35
35
|
|
|
36
36
|
getAllFiles(): string[];
|
|
37
|
-
|
|
37
|
+
getOrComputeSha1(filename: string): Promise<{sha1: string; content?: Buffer}>;
|
|
38
38
|
getWatcher(): EventEmitter;
|
|
39
39
|
end(): void;
|
|
40
40
|
|
|
@@ -24,13 +24,6 @@ function getOrCreateMap(map, field) {
|
|
|
24
24
|
}
|
|
25
25
|
return subMap;
|
|
26
26
|
}
|
|
27
|
-
const missingSha1Error = (mixedPath) =>
|
|
28
|
-
new Error(`Failed to get the SHA-1 for: ${mixedPath}.
|
|
29
|
-
Potential causes:
|
|
30
|
-
1) The file is not watched. Ensure it is under the configured \`projectRoot\` or \`watchFolders\`.
|
|
31
|
-
2) Check \`blockList\` in your metro.config.js and make sure it isn't excluding the file path.
|
|
32
|
-
3) The file may have been deleted since it was resolved - try refreshing your app.
|
|
33
|
-
4) Otherwise, this is a bug in Metro or the configured resolver - please report it.`);
|
|
34
27
|
class DependencyGraph extends EventEmitter {
|
|
35
28
|
constructor(config, options) {
|
|
36
29
|
super();
|
|
@@ -183,17 +176,15 @@ class DependencyGraph extends EventEmitter {
|
|
|
183
176
|
getAllFiles() {
|
|
184
177
|
return nullthrows(this._fileSystem).getAllFiles();
|
|
185
178
|
}
|
|
186
|
-
|
|
187
|
-
const sha1 = this._fileSystem.getSha1(filename);
|
|
188
|
-
if (!sha1) {
|
|
189
|
-
throw missingSha1Error(filename);
|
|
190
|
-
}
|
|
191
|
-
return sha1;
|
|
192
|
-
}
|
|
193
|
-
async unstable_getOrComputeSha1(mixedPath) {
|
|
179
|
+
async getOrComputeSha1(mixedPath) {
|
|
194
180
|
const result = await this._fileSystem.getOrComputeSha1(mixedPath);
|
|
195
181
|
if (!result || !result.sha1) {
|
|
196
|
-
throw
|
|
182
|
+
throw new Error(`Failed to get the SHA-1 for: ${mixedPath}.
|
|
183
|
+
Potential causes:
|
|
184
|
+
1) The file is not watched. Ensure it is under the configured \`projectRoot\` or \`watchFolders\`.
|
|
185
|
+
2) Check \`blockList\` in your metro.config.js and make sure it isn't excluding the file path.
|
|
186
|
+
3) The file may have been deleted since it was resolved - try refreshing your app.
|
|
187
|
+
4) Otherwise, this is a bug in Metro or the configured resolver - please report it.`);
|
|
197
188
|
}
|
|
198
189
|
return result;
|
|
199
190
|
}
|
|
@@ -55,14 +55,6 @@ function getOrCreateMap<T>(
|
|
|
55
55
|
return subMap;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const missingSha1Error = (mixedPath: string) =>
|
|
59
|
-
new Error(`Failed to get the SHA-1 for: ${mixedPath}.
|
|
60
|
-
Potential causes:
|
|
61
|
-
1) The file is not watched. Ensure it is under the configured \`projectRoot\` or \`watchFolders\`.
|
|
62
|
-
2) Check \`blockList\` in your metro.config.js and make sure it isn't excluding the file path.
|
|
63
|
-
3) The file may have been deleted since it was resolved - try refreshing your app.
|
|
64
|
-
4) Otherwise, this is a bug in Metro or the configured resolver - please report it.`);
|
|
65
|
-
|
|
66
58
|
class DependencyGraph extends EventEmitter {
|
|
67
59
|
_config: ConfigT;
|
|
68
60
|
_haste: MetroFileMap;
|
|
@@ -264,23 +256,20 @@ class DependencyGraph extends EventEmitter {
|
|
|
264
256
|
return nullthrows(this._fileSystem).getAllFiles();
|
|
265
257
|
}
|
|
266
258
|
|
|
267
|
-
getSha1(filename: string): string {
|
|
268
|
-
const sha1 = this._fileSystem.getSha1(filename);
|
|
269
|
-
if (!sha1) {
|
|
270
|
-
throw missingSha1Error(filename);
|
|
271
|
-
}
|
|
272
|
-
return sha1;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
259
|
/**
|
|
276
260
|
* Used when watcher.unstable_lazySha1 is true
|
|
277
261
|
*/
|
|
278
|
-
async
|
|
262
|
+
async getOrComputeSha1(
|
|
279
263
|
mixedPath: string,
|
|
280
264
|
): Promise<{content?: Buffer, sha1: string}> {
|
|
281
265
|
const result = await this._fileSystem.getOrComputeSha1(mixedPath);
|
|
282
266
|
if (!result || !result.sha1) {
|
|
283
|
-
throw
|
|
267
|
+
throw new Error(`Failed to get the SHA-1 for: ${mixedPath}.
|
|
268
|
+
Potential causes:
|
|
269
|
+
1) The file is not watched. Ensure it is under the configured \`projectRoot\` or \`watchFolders\`.
|
|
270
|
+
2) Check \`blockList\` in your metro.config.js and make sure it isn't excluding the file path.
|
|
271
|
+
3) The file may have been deleted since it was resolved - try refreshing your app.
|
|
272
|
+
4) Otherwise, this is a bug in Metro or the configured resolver - please report it.`);
|
|
284
273
|
}
|
|
285
274
|
return result;
|
|
286
275
|
}
|