metro 0.77.0 → 0.78.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 +20 -20
- package/src/DeltaBundler/Graph.js +1 -1
- package/src/DeltaBundler/Graph.js.flow +1 -1
- package/src/DeltaBundler/types.d.ts +2 -9
- package/src/DeltaBundler/types.flow.js.flow +4 -1
- package/src/HmrServer.js +9 -2
- package/src/HmrServer.js.flow +10 -3
- package/src/ModuleGraph/worker/collectDependencies.js +10 -2
- package/src/ModuleGraph/worker/collectDependencies.js.flow +12 -3
- package/src/Server/MultipartResponse.js +4 -0
- package/src/Server/MultipartResponse.js.flow +5 -0
- package/src/Server.js +43 -4
- package/src/Server.js.flow +42 -5
- package/src/commands/serve.js +1 -1
- package/src/commands/serve.js.flow +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.flow.js +1 -18
- package/src/index.flow.js.flow +3 -32
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +21 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +17 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js +18 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +29 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js +18 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +29 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js +18 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +17 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js +17 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +17 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js +20 -0
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +19 -0
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +21 -0
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +17 -0
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js +17 -0
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +17 -0
- package/src/integration_tests/metro.config.js +5 -3
- package/src/lib/createWebsocketServer.js +2 -0
- package/src/lib/createWebsocketServer.js.flow +5 -2
- package/src/lib/transformHelpers.js +2 -2
- package/src/lib/transformHelpers.js.flow +6 -3
- package/src/node-haste/DependencyGraph/ModuleResolution.js +139 -52
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +152 -51
- package/src/node-haste/DependencyGraph.d.ts +5 -2
- package/src/node-haste/DependencyGraph.js +3 -2
- package/src/node-haste/DependencyGraph.js.flow +7 -3
- package/src/node-haste/Package.js.flow +1 -1
package/src/index.flow.js.flow
CHANGED
|
@@ -16,8 +16,7 @@ import type {CustomResolverOptions} from 'metro-resolver';
|
|
|
16
16
|
import type {ReadOnlyGraph} from './DeltaBundler';
|
|
17
17
|
import type {ServerOptions} from './Server';
|
|
18
18
|
import type {OutputOptions, RequestOptions} from './shared/types.flow.js';
|
|
19
|
-
import type
|
|
20
|
-
import type {IncomingMessage, Server as HttpServer} from 'http';
|
|
19
|
+
import type {Server as HttpServer} from 'http';
|
|
21
20
|
import type {Server as HttpsServer} from 'https';
|
|
22
21
|
import type {
|
|
23
22
|
ConfigT,
|
|
@@ -26,7 +25,6 @@ import type {
|
|
|
26
25
|
Middleware,
|
|
27
26
|
} from 'metro-config/src/configTypes.flow';
|
|
28
27
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
29
|
-
import type {Duplex} from 'stream';
|
|
30
28
|
import typeof Yargs from 'yargs';
|
|
31
29
|
|
|
32
30
|
const makeBuildCommand = require('./commands/build');
|
|
@@ -49,7 +47,6 @@ const {
|
|
|
49
47
|
resolveConfig,
|
|
50
48
|
} = require('metro-config');
|
|
51
49
|
const {Terminal} = require('metro-core');
|
|
52
|
-
const {InspectorProxy} = require('metro-inspector-proxy');
|
|
53
50
|
const net = require('net');
|
|
54
51
|
const {parse} = require('url');
|
|
55
52
|
|
|
@@ -65,21 +62,11 @@ export type RunMetroOptions = {
|
|
|
65
62
|
waitForBundler?: boolean,
|
|
66
63
|
};
|
|
67
64
|
|
|
68
|
-
interface WebsocketServer extends EventEmitter {
|
|
69
|
-
handleUpgrade<T = WebsocketServer>(
|
|
70
|
-
request: IncomingMessage,
|
|
71
|
-
socket: Duplex,
|
|
72
|
-
upgradeHead: Buffer,
|
|
73
|
-
callback: (client: T, request: IncomingMessage) => void,
|
|
74
|
-
): void;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
65
|
export type RunServerOptions = $ReadOnly<{
|
|
78
66
|
hasReducedPerformance?: boolean,
|
|
79
67
|
host?: string,
|
|
80
68
|
onError?: (Error & {code?: string}) => void,
|
|
81
69
|
onReady?: (server: HttpServer | HttpsServer) => void,
|
|
82
|
-
runInspectorProxy?: boolean,
|
|
83
70
|
secureServerOptions?: Object,
|
|
84
71
|
secure?: boolean, // deprecated
|
|
85
72
|
secureCert?: string, // deprecated
|
|
@@ -88,7 +75,7 @@ export type RunServerOptions = $ReadOnly<{
|
|
|
88
75
|
waitForBundler?: boolean,
|
|
89
76
|
watch?: boolean,
|
|
90
77
|
websocketEndpoints?: $ReadOnly<{
|
|
91
|
-
[path: string]:
|
|
78
|
+
[path: string]: ws$WebSocketServer,
|
|
92
79
|
}>,
|
|
93
80
|
}>;
|
|
94
81
|
|
|
@@ -262,7 +249,7 @@ exports.runServer = async (
|
|
|
262
249
|
waitForBundler = false,
|
|
263
250
|
websocketEndpoints = {},
|
|
264
251
|
watch,
|
|
265
|
-
}: RunServerOptions,
|
|
252
|
+
}: RunServerOptions = {},
|
|
266
253
|
): Promise<HttpServer | HttpsServer> => {
|
|
267
254
|
await earlyPortCheck(host, config.server.port);
|
|
268
255
|
|
|
@@ -292,11 +279,6 @@ exports.runServer = async (
|
|
|
292
279
|
serverApp.use(handler);
|
|
293
280
|
}
|
|
294
281
|
|
|
295
|
-
let inspectorProxy: ?InspectorProxy = null;
|
|
296
|
-
if (config.server.runInspectorProxy) {
|
|
297
|
-
inspectorProxy = new InspectorProxy(config.projectRoot);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
282
|
let httpServer;
|
|
301
283
|
|
|
302
284
|
if (secure || secureServerOptions != null) {
|
|
@@ -333,9 +315,6 @@ exports.runServer = async (
|
|
|
333
315
|
|
|
334
316
|
websocketEndpoints = {
|
|
335
317
|
...websocketEndpoints,
|
|
336
|
-
...(inspectorProxy
|
|
337
|
-
? {...inspectorProxy.createWebSocketListeners(httpServer)}
|
|
338
|
-
: {}),
|
|
339
318
|
'/hot': createWebsocketServer({
|
|
340
319
|
websocketServer: new MetroHmrServer(
|
|
341
320
|
metroServer.getBundler(),
|
|
@@ -361,14 +340,6 @@ exports.runServer = async (
|
|
|
361
340
|
}
|
|
362
341
|
});
|
|
363
342
|
|
|
364
|
-
if (inspectorProxy) {
|
|
365
|
-
// TODO(hypuk): Refactor inspectorProxy.processRequest into separate request handlers
|
|
366
|
-
// so that we could provide routes (/json/list and /json/version) here.
|
|
367
|
-
// Currently this causes Metro to give warning about T31407894.
|
|
368
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
369
|
-
serverApp.use(inspectorProxy.processRequest.bind(inspectorProxy));
|
|
370
|
-
}
|
|
371
|
-
|
|
372
343
|
resolve(httpServer);
|
|
373
344
|
});
|
|
374
345
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
|
|
4
|
+
function _interopRequireDefault(obj) {
|
|
5
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
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
|
+
*/
|
|
16
|
+
|
|
17
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
18
|
+
|
|
19
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
20
|
+
|
|
21
|
+
global.x = _doesNotExist.default;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
12
|
+
import type DoesNotExistT from './does-not-exist';
|
|
13
|
+
|
|
14
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
15
|
+
import DoesNotExist from './does-not-exist';
|
|
16
|
+
|
|
17
|
+
global.x = (DoesNotExist: DoesNotExistT);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _doesNotExist = require("./does-not'\"-exist");
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/* eslint-disable no-unused-vars */
|
|
15
|
+
|
|
16
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
17
|
+
|
|
18
|
+
global.x = _doesNotExist.aaaaaaaaaa;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* eslint-disable no-unused-vars */
|
|
12
|
+
|
|
13
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
14
|
+
import type DoesNotExistT from './does-not\'"-exist';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
aaaaaaaaaa,
|
|
18
|
+
bbbbbbbbbb,
|
|
19
|
+
cccccccccc,
|
|
20
|
+
dddddddddd,
|
|
21
|
+
eeeeeeeeee,
|
|
22
|
+
ffffffffff,
|
|
23
|
+
gggggggggg,
|
|
24
|
+
hhhhhhhhhh,
|
|
25
|
+
iiiiiiiiii,
|
|
26
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
27
|
+
} from './does-not\'"-exist';
|
|
28
|
+
|
|
29
|
+
global.x = (aaaaaaaaaa: DoesNotExistT);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _doesNotExist = require("./does-not-exist");
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/* eslint-disable no-unused-vars */
|
|
15
|
+
|
|
16
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
17
|
+
|
|
18
|
+
global.x = _doesNotExist.aaaaaaaaaa;
|
package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* eslint-disable no-unused-vars */
|
|
12
|
+
|
|
13
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
14
|
+
import type DoesNotExistT from './does-not-exist';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
aaaaaaaaaa,
|
|
18
|
+
bbbbbbbbbb,
|
|
19
|
+
cccccccccc,
|
|
20
|
+
dddddddddd,
|
|
21
|
+
eeeeeeeeee,
|
|
22
|
+
ffffffffff,
|
|
23
|
+
gggggggggg,
|
|
24
|
+
hhhhhhhhhh,
|
|
25
|
+
iiiiiiiiii,
|
|
26
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
27
|
+
} from './does-not-exist';
|
|
28
|
+
|
|
29
|
+
global.x = (aaaaaaaaaa: DoesNotExistT);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* @format
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
14
|
+
|
|
15
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
16
|
+
const DoesNotExist = require("./foo" /* ./foo */);
|
|
17
|
+
|
|
18
|
+
global.x = DoesNotExist;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
12
|
+
import type DoesNotExistT from './foo';
|
|
13
|
+
|
|
14
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
15
|
+
const DoesNotExist = require('./foo' /* ./foo */);
|
|
16
|
+
|
|
17
|
+
global.x = (DoesNotExist: DoesNotExistT);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* @format
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
14
|
+
|
|
15
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
16
|
+
const DoesNotExist = require("./does-not-exist");
|
|
17
|
+
global.x = DoesNotExist;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
12
|
+
import type DoesNotExistT from './does-not-exist';
|
|
13
|
+
|
|
14
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
15
|
+
const DoesNotExist = require('./does-not-exist');
|
|
16
|
+
|
|
17
|
+
global.x = (DoesNotExist: DoesNotExistT);
|
package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _doesNotExist = require("./does-not'\"-exist");
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @format
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/* eslint-disable no-unused-vars */
|
|
15
|
+
|
|
16
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
17
|
+
|
|
18
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
19
|
+
|
|
20
|
+
global.x = _doesNotExist.DoesNotExist;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* eslint-disable no-unused-vars */
|
|
12
|
+
|
|
13
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
14
|
+
import type DoesNotExistT from './does-not\'"-exist';
|
|
15
|
+
|
|
16
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
17
|
+
import {DoesNotExist} from './does-not\'"-exist';
|
|
18
|
+
|
|
19
|
+
global.x = (DoesNotExist: DoesNotExistT);
|
package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
|
|
4
|
+
function _interopRequireDefault(obj) {
|
|
5
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
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
|
+
*/
|
|
16
|
+
|
|
17
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
18
|
+
|
|
19
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
20
|
+
|
|
21
|
+
global.x = _doesNotExist.default;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
12
|
+
import type DoesNotExistT from './does-not-exist';
|
|
13
|
+
|
|
14
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
15
|
+
import DoesNotExist from './does-not-exist';
|
|
16
|
+
|
|
17
|
+
global.x = (DoesNotExist: DoesNotExistT);
|
package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* @format
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
14
|
+
|
|
15
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
16
|
+
const DoesNotExist = require("./does-not-exist");
|
|
17
|
+
global.x = DoesNotExist;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
12
|
+
import type DoesNotExistT from './does-not-exist';
|
|
13
|
+
|
|
14
|
+
// $FlowExpectedError[cannot-resolve-module]
|
|
15
|
+
const DoesNotExist = require('./does-not-exist');
|
|
16
|
+
|
|
17
|
+
global.x = (DoesNotExist: DoesNotExistT);
|
|
@@ -32,14 +32,16 @@ module.exports = {
|
|
|
32
32
|
"metro-runtime/src/modules/asyncRequire"
|
|
33
33
|
),
|
|
34
34
|
babelTransformerPath: require.resolve(
|
|
35
|
-
"
|
|
35
|
+
"@react-native/metro-babel-transformer"
|
|
36
36
|
),
|
|
37
37
|
enableBabelRCLookup: false,
|
|
38
38
|
enableBabelRuntime: false,
|
|
39
|
-
getTransformOptions: async () => ({
|
|
39
|
+
getTransformOptions: async (entryFiles) => ({
|
|
40
40
|
transform: {
|
|
41
41
|
experimentalImportSupport: true,
|
|
42
|
-
inlineRequires:
|
|
42
|
+
inlineRequires: entryFiles.some((filePath) =>
|
|
43
|
+
filePath.includes("inline-requires")
|
|
44
|
+
),
|
|
43
45
|
},
|
|
44
46
|
preloadedModules: false,
|
|
45
47
|
ramGroups: [],
|
|
@@ -35,6 +35,7 @@ module.exports = function createWebsocketServer({ websocketServer }) {
|
|
|
35
35
|
const url = req.url;
|
|
36
36
|
const sendFn = (...args) => {
|
|
37
37
|
if (connected) {
|
|
38
|
+
// $FlowFixMe[incompatible-call]
|
|
38
39
|
ws.send(...args);
|
|
39
40
|
}
|
|
40
41
|
};
|
|
@@ -44,6 +45,7 @@ module.exports = function createWebsocketServer({ websocketServer }) {
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
ws.on("error", (e) => {
|
|
48
|
+
// $FlowFixMe[incompatible-call]
|
|
47
49
|
websocketServer.onClientError && websocketServer.onClientError(client, e);
|
|
48
50
|
});
|
|
49
51
|
ws.on("close", () => {
|
|
@@ -19,7 +19,7 @@ type WebsocketServiceInterface<T> = interface {
|
|
|
19
19
|
+onClientError?: (client: T, e: ErrorEvent) => mixed,
|
|
20
20
|
+onClientMessage?: (
|
|
21
21
|
client: T,
|
|
22
|
-
message: string
|
|
22
|
+
message: string | Buffer | ArrayBuffer | Array<Buffer>,
|
|
23
23
|
sendFn: (data: string) => void,
|
|
24
24
|
) => mixed,
|
|
25
25
|
};
|
|
@@ -42,7 +42,7 @@ type HMROptions<TClient> = {
|
|
|
42
42
|
|
|
43
43
|
module.exports = function createWebsocketServer<TClient: Object>({
|
|
44
44
|
websocketServer,
|
|
45
|
-
}: HMROptions<TClient>):
|
|
45
|
+
}: HMROptions<TClient>): ws.Server {
|
|
46
46
|
const wss = new ws.Server({
|
|
47
47
|
noServer: true,
|
|
48
48
|
});
|
|
@@ -53,6 +53,7 @@ module.exports = function createWebsocketServer<TClient: Object>({
|
|
|
53
53
|
|
|
54
54
|
const sendFn = (...args: Array<string>) => {
|
|
55
55
|
if (connected) {
|
|
56
|
+
// $FlowFixMe[incompatible-call]
|
|
56
57
|
ws.send(...args);
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -65,6 +66,7 @@ module.exports = function createWebsocketServer<TClient: Object>({
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
ws.on('error', e => {
|
|
69
|
+
// $FlowFixMe[incompatible-call]
|
|
68
70
|
websocketServer.onClientError && websocketServer.onClientError(client, e);
|
|
69
71
|
});
|
|
70
72
|
|
|
@@ -79,5 +81,6 @@ module.exports = function createWebsocketServer<TClient: Object>({
|
|
|
79
81
|
websocketServer.onClientMessage(client, message, sendFn);
|
|
80
82
|
});
|
|
81
83
|
});
|
|
84
|
+
|
|
82
85
|
return wss;
|
|
83
86
|
};
|
|
@@ -166,10 +166,10 @@ function getType(type, filePath, assetExts) {
|
|
|
166
166
|
}
|
|
167
167
|
async function getResolveDependencyFn(bundler, platform, resolverOptions) {
|
|
168
168
|
const dependencyGraph = await await bundler.getDependencyGraph();
|
|
169
|
-
return (from,
|
|
169
|
+
return (from, dependency) =>
|
|
170
170
|
dependencyGraph.resolveDependency(
|
|
171
171
|
from,
|
|
172
|
-
|
|
172
|
+
dependency,
|
|
173
173
|
platform ?? null,
|
|
174
174
|
resolverOptions
|
|
175
175
|
);
|
|
@@ -16,6 +16,7 @@ import type DeltaBundler, {TransformFn} from '../DeltaBundler';
|
|
|
16
16
|
import type {
|
|
17
17
|
BundlerResolution,
|
|
18
18
|
TransformInputOptions,
|
|
19
|
+
TransformResultDependency,
|
|
19
20
|
} from '../DeltaBundler/types.flow';
|
|
20
21
|
import type {TransformOptions} from '../DeltaBundler/Worker';
|
|
21
22
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
@@ -204,13 +205,15 @@ async function getResolveDependencyFn(
|
|
|
204
205
|
bundler: Bundler,
|
|
205
206
|
platform: ?string,
|
|
206
207
|
resolverOptions: ResolverInputOptions,
|
|
207
|
-
): Promise<
|
|
208
|
+
): Promise<
|
|
209
|
+
(from: string, dependency: TransformResultDependency) => BundlerResolution,
|
|
210
|
+
> {
|
|
208
211
|
const dependencyGraph = await await bundler.getDependencyGraph();
|
|
209
212
|
|
|
210
|
-
return (from: string,
|
|
213
|
+
return (from: string, dependency: TransformResultDependency) =>
|
|
211
214
|
dependencyGraph.resolveDependency(
|
|
212
215
|
from,
|
|
213
|
-
|
|
216
|
+
dependency,
|
|
214
217
|
platform ?? null,
|
|
215
218
|
resolverOptions,
|
|
216
219
|
);
|