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
|
@@ -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
|
*/
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import type {RunBuildOptions} from '../index';
|
|
13
13
|
import type {CustomTransformOptions} from 'metro-babel-transformer';
|
|
14
14
|
import type {CustomResolverOptions} from 'metro-resolver';
|
|
15
|
-
import type {
|
|
15
|
+
import type {CommandModule} from 'yargs';
|
|
16
16
|
import typeof Yargs from 'yargs';
|
|
17
17
|
|
|
18
18
|
import {makeAsyncCommand} from '../cli-utils';
|
|
@@ -24,7 +24,9 @@ import {Terminal} from 'metro-core';
|
|
|
24
24
|
const term = new Terminal(process.stdout);
|
|
25
25
|
const updateReporter = new TerminalReporter(term);
|
|
26
26
|
|
|
27
|
-
type Args =
|
|
27
|
+
type Args = Readonly<{
|
|
28
|
+
_: unknown,
|
|
29
|
+
$0: unknown,
|
|
28
30
|
config?: string,
|
|
29
31
|
dev?: boolean,
|
|
30
32
|
entry: string,
|
|
@@ -34,18 +36,16 @@ type Args = $ReadOnly<{
|
|
|
34
36
|
out: string,
|
|
35
37
|
outputType?: string,
|
|
36
38
|
platform?: string,
|
|
37
|
-
projectRoots?:
|
|
39
|
+
projectRoots?: ReadonlyArray<string>,
|
|
38
40
|
resetCache?: boolean,
|
|
39
41
|
sourceMap?: boolean,
|
|
40
42
|
sourceMapUrl?: string,
|
|
41
43
|
transformOption: CustomTransformOptions,
|
|
42
44
|
resolverOption: CustomResolverOptions,
|
|
45
|
+
...
|
|
43
46
|
}>;
|
|
44
47
|
|
|
45
|
-
export default (): {
|
|
46
|
-
...ModuleObject,
|
|
47
|
-
handler: Function,
|
|
48
|
-
} => ({
|
|
48
|
+
export default (): CommandModule => ({
|
|
49
49
|
command: 'build <entry>',
|
|
50
50
|
desc: 'Generates a JavaScript bundle containing the specified entrypoint and its descendants',
|
|
51
51
|
|
|
@@ -76,7 +76,7 @@ export default (): {
|
|
|
76
76
|
type: 'string',
|
|
77
77
|
array: true,
|
|
78
78
|
alias: 'transformer-option',
|
|
79
|
-
coerce:
|
|
79
|
+
coerce: parseKeyValueParamArray as $FlowFixMe,
|
|
80
80
|
describe:
|
|
81
81
|
'Custom transform options of the form key=value. URL-encoded. May be specified multiple times.',
|
|
82
82
|
});
|
|
@@ -84,7 +84,7 @@ export default (): {
|
|
|
84
84
|
yargs.option('resolver-option', {
|
|
85
85
|
type: 'string',
|
|
86
86
|
array: true,
|
|
87
|
-
coerce:
|
|
87
|
+
coerce: parseKeyValueParamArray as $FlowFixMe,
|
|
88
88
|
describe:
|
|
89
89
|
'Custom resolver options of the form key=value. URL-encoded. May be specified multiple times.',
|
|
90
90
|
});
|
|
@@ -94,6 +94,7 @@ export default (): {
|
|
|
94
94
|
},
|
|
95
95
|
|
|
96
96
|
handler: makeAsyncCommand(async (argv: Args) => {
|
|
97
|
+
// $FlowFixMe[incompatible-type] argv has extra props.
|
|
97
98
|
const config = await loadConfig(argv);
|
|
98
99
|
const options: RunBuildOptions = {
|
|
99
100
|
entry: argv.entry,
|
|
@@ -11,7 +11,11 @@ var _metroConfig = require("metro-config");
|
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
12
|
var _util = require("util");
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
14
|
+
return e && e.__esModule
|
|
15
|
+
? e
|
|
16
|
+
: {
|
|
17
|
+
default: e,
|
|
18
|
+
};
|
|
15
19
|
}
|
|
16
20
|
async function dependencies(args, config) {
|
|
17
21
|
const rootModuleAbsolutePath = args.entryFile;
|
|
@@ -4,13 +4,13 @@
|
|
|
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
|
*/
|
|
11
11
|
|
|
12
12
|
import type {ConfigT} from 'metro-config';
|
|
13
|
-
import type {
|
|
13
|
+
import type {CommandModule} from 'yargs';
|
|
14
14
|
import typeof Yargs from 'yargs';
|
|
15
15
|
|
|
16
16
|
import {makeAsyncCommand} from '../cli-utils';
|
|
@@ -20,7 +20,9 @@ import {loadConfig} from 'metro-config';
|
|
|
20
20
|
import path from 'path';
|
|
21
21
|
import {promisify} from 'util';
|
|
22
22
|
|
|
23
|
-
type Args =
|
|
23
|
+
type Args = Readonly<{
|
|
24
|
+
_: unknown,
|
|
25
|
+
$0: unknown,
|
|
24
26
|
entryFile: string,
|
|
25
27
|
output?: string,
|
|
26
28
|
platform?: string,
|
|
@@ -28,6 +30,7 @@ type Args = $ReadOnly<{
|
|
|
28
30
|
maxWorkers?: number,
|
|
29
31
|
dev: boolean,
|
|
30
32
|
verbose: boolean,
|
|
33
|
+
...
|
|
31
34
|
}>;
|
|
32
35
|
|
|
33
36
|
async function dependencies(args: Args, config: ConfigT) {
|
|
@@ -82,7 +85,7 @@ async function dependencies(args: Args, config: ConfigT) {
|
|
|
82
85
|
: Promise.resolve();
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
export default ():
|
|
88
|
+
export default (): CommandModule => ({
|
|
86
89
|
command: 'get-dependencies [entryFile]',
|
|
87
90
|
desc: 'List all dependencies that will be bundled for a given entry point',
|
|
88
91
|
builder: (yargs: Yargs) => {
|
|
@@ -123,6 +126,7 @@ export default (): {...ModuleObject, handler: Function} => ({
|
|
|
123
126
|
});
|
|
124
127
|
},
|
|
125
128
|
handler: makeAsyncCommand(async (argv: Args) => {
|
|
129
|
+
// $FlowFixMe[incompatible-type] argv has extra props.
|
|
126
130
|
const config = await loadConfig(argv);
|
|
127
131
|
await dependencies(argv, config);
|
|
128
132
|
}),
|
package/src/commands/serve.js
CHANGED
|
@@ -4,36 +4,37 @@
|
|
|
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
|
*/
|
|
11
11
|
|
|
12
|
-
import type {
|
|
12
|
+
import type {ServerOptions as HttpsServerOptions} from 'https';
|
|
13
|
+
import type {CommandModule} from 'yargs';
|
|
13
14
|
import typeof Yargs from 'yargs';
|
|
14
15
|
|
|
15
16
|
import {makeAsyncCommand, watchFile} from '../cli-utils';
|
|
16
17
|
import {loadConfig, resolveConfig} from 'metro-config';
|
|
17
18
|
import {promisify} from 'util';
|
|
18
19
|
|
|
19
|
-
type Args =
|
|
20
|
-
|
|
20
|
+
type Args = Readonly<{
|
|
21
|
+
_: unknown,
|
|
22
|
+
$0: unknown,
|
|
23
|
+
projectRoots?: ReadonlyArray<string>,
|
|
21
24
|
host: string,
|
|
22
25
|
port: number,
|
|
23
26
|
maxWorkers?: number,
|
|
24
27
|
secure?: boolean,
|
|
25
28
|
secureKey?: string,
|
|
26
29
|
secureCert?: string,
|
|
27
|
-
secureServerOptions?:
|
|
30
|
+
secureServerOptions?: HttpsServerOptions,
|
|
28
31
|
hmrEnabled?: boolean,
|
|
29
32
|
config?: string,
|
|
30
33
|
resetCache?: boolean,
|
|
34
|
+
...
|
|
31
35
|
}>;
|
|
32
36
|
|
|
33
|
-
export default (): {
|
|
34
|
-
...ModuleObject,
|
|
35
|
-
handler: Function,
|
|
36
|
-
} => ({
|
|
37
|
+
export default (): CommandModule => ({
|
|
37
38
|
command: 'serve',
|
|
38
39
|
aliases: ['start'],
|
|
39
40
|
desc: 'Starts Metro on the given port, building bundles on the fly',
|
|
@@ -91,6 +92,7 @@ export default (): {
|
|
|
91
92
|
await promisify(server.close).call(server);
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
// $FlowFixMe[incompatible-type] argv has extra props.
|
|
94
96
|
const config = await loadConfig(argv);
|
|
95
97
|
|
|
96
98
|
// Inline require() to avoid circular dependency with ../index
|
|
@@ -98,6 +100,8 @@ export default (): {
|
|
|
98
100
|
const MetroApi = require('../index');
|
|
99
101
|
|
|
100
102
|
const {
|
|
103
|
+
_,
|
|
104
|
+
$0: _0,
|
|
101
105
|
config: _config,
|
|
102
106
|
hmrEnabled: _hmrEnabled,
|
|
103
107
|
maxWorkers: _maxWorkers,
|
|
@@ -108,6 +112,7 @@ export default (): {
|
|
|
108
112
|
} = argv;
|
|
109
113
|
({httpServer: server} = await MetroApi.runServer(
|
|
110
114
|
config,
|
|
115
|
+
// $FlowFixMe[incompatible-exact] argv has extra props.
|
|
111
116
|
runServerOptions,
|
|
112
117
|
));
|
|
113
118
|
|
package/src/index.flow.js
CHANGED
|
@@ -71,31 +71,42 @@ var _metroConfig = require("metro-config");
|
|
|
71
71
|
var _metroCore = require("metro-core");
|
|
72
72
|
var _net = _interopRequireDefault(require("net"));
|
|
73
73
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
74
|
-
function
|
|
75
|
-
if ("function"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
92
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
93
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
74
|
+
function _interopRequireWildcard(e, t) {
|
|
75
|
+
if ("function" == typeof WeakMap)
|
|
76
|
+
var r = new WeakMap(),
|
|
77
|
+
n = new WeakMap();
|
|
78
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
79
|
+
if (!t && e && e.__esModule) return e;
|
|
80
|
+
var o,
|
|
81
|
+
i,
|
|
82
|
+
f = {
|
|
83
|
+
__proto__: null,
|
|
84
|
+
default: e,
|
|
85
|
+
};
|
|
86
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
87
|
+
return f;
|
|
88
|
+
if ((o = t ? n : r)) {
|
|
89
|
+
if (o.has(e)) return o.get(e);
|
|
90
|
+
o.set(e, f);
|
|
94
91
|
}
|
|
95
|
-
|
|
92
|
+
for (const t in e)
|
|
93
|
+
"default" !== t &&
|
|
94
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
95
|
+
((i =
|
|
96
|
+
(o = Object.defineProperty) &&
|
|
97
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
98
|
+
(i.get || i.set)
|
|
99
|
+
? o(f, t, i)
|
|
100
|
+
: (f[t] = e[t]));
|
|
101
|
+
return f;
|
|
102
|
+
})(e, t);
|
|
96
103
|
}
|
|
97
104
|
function _interopRequireDefault(e) {
|
|
98
|
-
return e && e.__esModule
|
|
105
|
+
return e && e.__esModule
|
|
106
|
+
? e
|
|
107
|
+
: {
|
|
108
|
+
default: e,
|
|
109
|
+
};
|
|
99
110
|
}
|
|
100
111
|
const DEFAULTS = _Server.default.DEFAULT_BUNDLE_OPTIONS;
|
|
101
112
|
async function getConfig(config) {
|
|
@@ -190,7 +201,7 @@ const runServer = async (
|
|
|
190
201
|
secureKey,
|
|
191
202
|
unstable_extraMiddleware,
|
|
192
203
|
waitForBundler = false,
|
|
193
|
-
websocketEndpoints = {},
|
|
204
|
+
websocketEndpoints: userWebsocketEndpoints = {},
|
|
194
205
|
watch,
|
|
195
206
|
} = {},
|
|
196
207
|
) => {
|
|
@@ -219,7 +230,7 @@ const runServer = async (
|
|
|
219
230
|
}
|
|
220
231
|
serverApp.use(middleware);
|
|
221
232
|
let httpServer;
|
|
222
|
-
if (secure || secureServerOptions != null) {
|
|
233
|
+
if (secure === true || secureServerOptions != null) {
|
|
223
234
|
let options = secureServerOptions;
|
|
224
235
|
if (typeof secureKey === "string" && typeof secureCert === "string") {
|
|
225
236
|
options = {
|
|
@@ -247,8 +258,8 @@ const runServer = async (
|
|
|
247
258
|
port,
|
|
248
259
|
family,
|
|
249
260
|
});
|
|
250
|
-
websocketEndpoints = {
|
|
251
|
-
...
|
|
261
|
+
const websocketEndpoints = {
|
|
262
|
+
...userWebsocketEndpoints,
|
|
252
263
|
"/hot": (0, _createWebsocketServer.default)({
|
|
253
264
|
websocketServer: new _HmrServer.default(
|
|
254
265
|
metroServer.getBundler(),
|
|
@@ -349,7 +360,7 @@ const runBuild = async (
|
|
|
349
360
|
if (onComplete) {
|
|
350
361
|
onComplete();
|
|
351
362
|
}
|
|
352
|
-
if (out || bundleOut) {
|
|
363
|
+
if (out != null || bundleOut != null) {
|
|
353
364
|
const bundleOutput =
|
|
354
365
|
bundleOut ?? (0, _nullthrows.default)(out).replace(/(\.js)?$/, ".js");
|
|
355
366
|
const sourcemapOutput =
|
package/src/index.flow.js.flow
CHANGED
|
@@ -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
|
*/
|
|
@@ -15,7 +15,10 @@ import type {ServerOptions} from './Server';
|
|
|
15
15
|
import type {BuildOptions, OutputOptions, RequestOptions} from './shared/types';
|
|
16
16
|
import type {HandleFunction} from 'connect';
|
|
17
17
|
import type {Server as HttpServer} from 'http';
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
Server as HttpsServer,
|
|
20
|
+
ServerOptions as HttpsServerOptions,
|
|
21
|
+
} from 'https';
|
|
19
22
|
import type {TransformProfile} from 'metro-babel-transformer';
|
|
20
23
|
import type {
|
|
21
24
|
ConfigT,
|
|
@@ -25,6 +28,7 @@ import type {
|
|
|
25
28
|
} from 'metro-config';
|
|
26
29
|
import type {CustomResolverOptions} from 'metro-resolver';
|
|
27
30
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
31
|
+
import type {Server as WebSocketServer} from 'ws';
|
|
28
32
|
import typeof Yargs from 'yargs';
|
|
29
33
|
|
|
30
34
|
import makeBuildCommand from './commands/build';
|
|
@@ -65,21 +69,21 @@ export type RunMetroOptions = {
|
|
|
65
69
|
waitForBundler?: boolean,
|
|
66
70
|
};
|
|
67
71
|
|
|
68
|
-
export type RunServerOptions =
|
|
72
|
+
export type RunServerOptions = Readonly<{
|
|
69
73
|
hasReducedPerformance?: boolean,
|
|
70
74
|
host?: string,
|
|
71
75
|
onError?: (Error & {code?: string}) => void,
|
|
72
76
|
onReady?: (server: HttpServer | HttpsServer) => void,
|
|
73
77
|
onClose?: () => void,
|
|
74
|
-
secureServerOptions?:
|
|
78
|
+
secureServerOptions?: HttpsServerOptions,
|
|
75
79
|
secure?: boolean, // deprecated
|
|
76
80
|
secureCert?: string, // deprecated
|
|
77
81
|
secureKey?: string, // deprecated
|
|
78
|
-
unstable_extraMiddleware?:
|
|
82
|
+
unstable_extraMiddleware?: ReadonlyArray<HandleFunction>,
|
|
79
83
|
waitForBundler?: boolean,
|
|
80
84
|
watch?: boolean,
|
|
81
|
-
websocketEndpoints?:
|
|
82
|
-
[path: string]:
|
|
85
|
+
websocketEndpoints?: Readonly<{
|
|
86
|
+
[path: string]: WebSocketServer,
|
|
83
87
|
}>,
|
|
84
88
|
}>;
|
|
85
89
|
|
|
@@ -88,7 +92,7 @@ export type RunServerResult = {
|
|
|
88
92
|
};
|
|
89
93
|
|
|
90
94
|
type BuildGraphOptions = {
|
|
91
|
-
entries:
|
|
95
|
+
entries: ReadonlyArray<string>,
|
|
92
96
|
customTransformOptions?: CustomTransformOptions,
|
|
93
97
|
dev?: boolean,
|
|
94
98
|
minify?: boolean,
|
|
@@ -108,7 +112,7 @@ export type RunBuildOptions = {
|
|
|
108
112
|
onComplete?: () => void,
|
|
109
113
|
onProgress?: (transformedFileCount: number, totalFileCount: number) => void,
|
|
110
114
|
minify?: boolean,
|
|
111
|
-
output?:
|
|
115
|
+
output?: Readonly<{
|
|
112
116
|
build: (
|
|
113
117
|
MetroServer,
|
|
114
118
|
RequestOptions,
|
|
@@ -116,7 +120,7 @@ export type RunBuildOptions = {
|
|
|
116
120
|
) => Promise<{
|
|
117
121
|
code: string,
|
|
118
122
|
map: string,
|
|
119
|
-
assets?:
|
|
123
|
+
assets?: ReadonlyArray<AssetData>,
|
|
120
124
|
...
|
|
121
125
|
}>,
|
|
122
126
|
save: (
|
|
@@ -127,7 +131,7 @@ export type RunBuildOptions = {
|
|
|
127
131
|
},
|
|
128
132
|
OutputOptions,
|
|
129
133
|
(logMessage: string) => void,
|
|
130
|
-
) => Promise<
|
|
134
|
+
) => Promise<unknown>,
|
|
131
135
|
...
|
|
132
136
|
}>,
|
|
133
137
|
platform?: string,
|
|
@@ -141,12 +145,13 @@ export type RunBuildOptions = {
|
|
|
141
145
|
export type RunBuildResult = {
|
|
142
146
|
code: string,
|
|
143
147
|
map: string,
|
|
144
|
-
assets?:
|
|
148
|
+
assets?: ReadonlyArray<AssetData>,
|
|
145
149
|
...
|
|
146
150
|
};
|
|
147
151
|
|
|
148
|
-
type BuildCommandOptions = {} | null;
|
|
149
|
-
type ServeCommandOptions = {} | null;
|
|
152
|
+
type BuildCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
153
|
+
type ServeCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
154
|
+
type DependenciesCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
150
155
|
|
|
151
156
|
export {Terminal, JsonReporter, TerminalReporter};
|
|
152
157
|
|
|
@@ -263,7 +268,7 @@ export const runServer = async (
|
|
|
263
268
|
secureKey, // deprecated
|
|
264
269
|
unstable_extraMiddleware,
|
|
265
270
|
waitForBundler = false,
|
|
266
|
-
websocketEndpoints = {},
|
|
271
|
+
websocketEndpoints: userWebsocketEndpoints = {},
|
|
267
272
|
watch,
|
|
268
273
|
}: RunServerOptions = {},
|
|
269
274
|
): Promise<RunServerResult> => {
|
|
@@ -302,7 +307,7 @@ export const runServer = async (
|
|
|
302
307
|
|
|
303
308
|
let httpServer;
|
|
304
309
|
|
|
305
|
-
if (secure || secureServerOptions != null) {
|
|
310
|
+
if (secure === true || secureServerOptions != null) {
|
|
306
311
|
let options = secureServerOptions;
|
|
307
312
|
if (typeof secureKey === 'string' && typeof secureCert === 'string') {
|
|
308
313
|
options = {
|
|
@@ -333,8 +338,8 @@ export const runServer = async (
|
|
|
333
338
|
family,
|
|
334
339
|
});
|
|
335
340
|
|
|
336
|
-
websocketEndpoints = {
|
|
337
|
-
...
|
|
341
|
+
const websocketEndpoints = {
|
|
342
|
+
...userWebsocketEndpoints,
|
|
338
343
|
'/hot': createWebsocketServer({
|
|
339
344
|
websocketServer: new MetroHmrServer(
|
|
340
345
|
metroServer.getBundler(),
|
|
@@ -441,7 +446,7 @@ export const runBuild = async (
|
|
|
441
446
|
onComplete();
|
|
442
447
|
}
|
|
443
448
|
|
|
444
|
-
if (out || bundleOut) {
|
|
449
|
+
if (out != null || bundleOut != null) {
|
|
445
450
|
const bundleOutput =
|
|
446
451
|
bundleOut ?? nullthrows(out).replace(/(\.js)?$/, '.js');
|
|
447
452
|
|
|
@@ -510,7 +515,7 @@ export const buildGraph = async function (
|
|
|
510
515
|
type AttachMetroCLIOptions = {
|
|
511
516
|
build?: BuildCommandOptions,
|
|
512
517
|
serve?: ServeCommandOptions,
|
|
513
|
-
dependencies?:
|
|
518
|
+
dependencies?: DependenciesCommandOptions,
|
|
514
519
|
...
|
|
515
520
|
};
|
|
516
521
|
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
|
|
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
|
global.x = _doesNotExist.default;
|
package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
|
|
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
|
global.x = _doesNotExist.default;
|
|
@@ -30,30 +30,41 @@ var _exportPrimitiveDefault = _interopRequireWildcard(
|
|
|
30
30
|
var _export3 = _interopRequireDefault(require("./export-3"));
|
|
31
31
|
var _export4 = require("./export-4");
|
|
32
32
|
function _interopRequireDefault(e) {
|
|
33
|
-
return e && e.__esModule
|
|
33
|
+
return e && e.__esModule
|
|
34
|
+
? e
|
|
35
|
+
: {
|
|
36
|
+
default: e,
|
|
37
|
+
};
|
|
34
38
|
}
|
|
35
|
-
function
|
|
36
|
-
if ("function"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
53
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
54
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
39
|
+
function _interopRequireWildcard(e, t) {
|
|
40
|
+
if ("function" == typeof WeakMap)
|
|
41
|
+
var r = new WeakMap(),
|
|
42
|
+
n = new WeakMap();
|
|
43
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
44
|
+
if (!t && e && e.__esModule) return e;
|
|
45
|
+
var o,
|
|
46
|
+
i,
|
|
47
|
+
f = {
|
|
48
|
+
__proto__: null,
|
|
49
|
+
default: e,
|
|
50
|
+
};
|
|
51
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
52
|
+
return f;
|
|
53
|
+
if ((o = t ? n : r)) {
|
|
54
|
+
if (o.has(e)) return o.get(e);
|
|
55
|
+
o.set(e, f);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
for (const t in e)
|
|
58
|
+
"default" !== t &&
|
|
59
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
60
|
+
((i =
|
|
61
|
+
(o = Object.defineProperty) &&
|
|
62
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
63
|
+
(i.get || i.set)
|
|
64
|
+
? o(f, t, i)
|
|
65
|
+
: (f[t] = e[t]));
|
|
66
|
+
return f;
|
|
67
|
+
})(e, t);
|
|
57
68
|
}
|
|
58
69
|
const extraData = (exports.extraData = {
|
|
59
70
|
foo: _exportNull.foo,
|
|
@@ -29,7 +29,7 @@ export const extraData = {
|
|
|
29
29
|
importStar,
|
|
30
30
|
myDefault,
|
|
31
31
|
myFoo,
|
|
32
|
-
myFunction:
|
|
32
|
+
myFunction: myFunction() as string,
|
|
33
33
|
primitiveDefault,
|
|
34
34
|
primitiveFoo,
|
|
35
35
|
};
|
|
@@ -37,7 +37,7 @@ export const extraData = {
|
|
|
37
37
|
export const asyncImportCJS = import('./export-5');
|
|
38
38
|
export const asyncImportESM = import('./export-6');
|
|
39
39
|
|
|
40
|
-
export const asyncImportMaybeSyncCJS:
|
|
40
|
+
export const asyncImportMaybeSyncCJS: unknown =
|
|
41
41
|
require.unstable_importMaybeSync('./export-7');
|
|
42
|
-
export const asyncImportMaybeSyncESM:
|
|
42
|
+
export const asyncImportMaybeSyncESM: unknown =
|
|
43
43
|
require.unstable_importMaybeSync('./export-8');
|