metro 0.76.0 → 0.76.1
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 +24 -24
- package/src/Asset.d.ts +25 -0
- package/src/Bundler.d.ts +39 -0
- package/src/DeltaBundler/Graph.d.ts +40 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +18 -0
- package/src/DeltaBundler/Transformer.js +1 -2
- package/src/DeltaBundler/Transformer.js.flow +1 -2
- package/src/DeltaBundler/Worker.d.ts +47 -0
- package/src/DeltaBundler/types.d.ts +167 -0
- package/src/DeltaBundler.d.ts +58 -0
- package/src/HmrServer.js +1 -5
- package/src/HmrServer.js.flow +0 -5
- package/src/IncrementalBundler.d.ts +97 -0
- package/src/IncrementalBundler.js +1 -0
- package/src/IncrementalBundler.js.flow +1 -0
- package/src/ModuleGraph/worker/collectDependencies.d.ts +27 -0
- package/src/ModuleGraph/worker/collectDependencies.js +42 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +41 -36
- package/src/Server/MultipartResponse.d.ts +31 -0
- package/src/Server.d.ts +113 -0
- package/src/Server.js +11 -133
- package/src/Server.js.flow +12 -154
- package/src/cli/parseKeyValueParamArray.js +34 -0
- package/src/cli/parseKeyValueParamArray.js.flow +31 -0
- package/src/cli-utils.js.flow +2 -6
- package/src/cli.js +2 -0
- package/src/cli.js.flow +1 -0
- package/src/commands/build.js +34 -7
- package/src/commands/build.js.flow +50 -8
- package/src/commands/dependencies.js +11 -9
- package/src/commands/dependencies.js.flow +128 -0
- package/src/commands/serve.js +11 -4
- package/src/commands/serve.js.flow +26 -6
- package/src/index.d.ts +151 -0
- package/src/index.flow.js +8 -2
- package/src/index.flow.js.flow +18 -6
- package/src/lib/CountingSet.d.ts +48 -0
- package/src/lib/TerminalReporter.d.ts +27 -0
- package/src/lib/TerminalReporter.js +1 -4
- package/src/lib/TerminalReporter.js.flow +1 -5
- package/src/lib/contextModule.d.ts +22 -0
- package/src/lib/getGraphId.d.ts +11 -0
- package/src/lib/getGraphId.js +0 -1
- package/src/lib/getGraphId.js.flow +0 -1
- package/src/lib/getPrependedScripts.js +0 -9
- package/src/lib/getPrependedScripts.js.flow +0 -9
- package/src/lib/parseOptionsFromUrl.js +1 -16
- package/src/lib/parseOptionsFromUrl.js.flow +0 -17
- package/src/lib/reporting.d.ts +140 -0
- package/src/lib/reporting.js.flow +0 -1
- package/src/lib/splitBundleOptions.js +0 -1
- package/src/lib/splitBundleOptions.js.flow +0 -1
- package/src/lib/transformHelpers.js +0 -1
- package/src/lib/transformHelpers.js.flow +0 -1
- package/src/node-haste/DependencyGraph/createHasteMap.js +0 -1
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +0 -1
- package/src/node-haste/DependencyGraph.d.ts +59 -0
- package/src/node-haste/DependencyGraph.js +1 -0
- package/src/node-haste/DependencyGraph.js.flow +1 -0
- package/src/shared/output/RamBundle/as-assets.js +1 -0
- package/src/shared/output/RamBundle/as-assets.js.flow +1 -0
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -0
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -0
- package/src/shared/output/bundle.d.ts +31 -0
- package/src/shared/types.d.ts +138 -0
- package/src/shared/types.flow.js.flow +2 -1
- package/types/Asset.d.ts +25 -0
- package/types/Bundler.d.ts +39 -0
- package/types/DeltaBundler/Graph.d.ts +40 -0
- package/types/DeltaBundler/Serializers/getRamBundleInfo.d.ts +18 -0
- package/types/DeltaBundler/Worker.d.ts +47 -0
- package/types/DeltaBundler/types.d.ts +167 -0
- package/types/DeltaBundler.d.ts +58 -0
- package/types/IncrementalBundler.d.ts +97 -0
- package/types/ModuleGraph/worker/collectDependencies.d.ts +27 -0
- package/types/Server/MultipartResponse.d.ts +31 -0
- package/types/Server.d.ts +113 -0
- package/types/index.d.ts +151 -0
- package/types/lib/CountingSet.d.ts +48 -0
- package/types/lib/TerminalReporter.d.ts +27 -0
- package/types/lib/contextModule.d.ts +22 -0
- package/types/lib/getGraphId.d.ts +11 -0
- package/types/lib/reporting.d.ts +140 -0
- package/types/node-haste/DependencyGraph.d.ts +59 -0
- package/types/shared/output/bundle.d.ts +31 -0
- package/types/shared/types.d.ts +138 -0
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +0 -81
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +0 -103
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +0 -61
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +0 -75
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +0 -40
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +0 -51
- package/src/lib/bundleToBytecode.js +0 -79
- package/src/lib/bundleToBytecode.js.flow +0 -97
|
@@ -74,7 +74,6 @@ async function getPrependedScripts(
|
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
77
|
-
const { compile } = require("metro-hermes-compiler");
|
|
78
77
|
const code = getPreludeCode({
|
|
79
78
|
isDev: dev,
|
|
80
79
|
globalPrefix,
|
|
@@ -95,14 +94,6 @@ function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
|
95
94
|
map: [],
|
|
96
95
|
},
|
|
97
96
|
},
|
|
98
|
-
{
|
|
99
|
-
type: "bytecode/script/virtual",
|
|
100
|
-
data: {
|
|
101
|
-
bytecode: compile(code, {
|
|
102
|
-
sourceURL: "__prelude__.virtual.js",
|
|
103
|
-
}).bytecode,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
97
|
],
|
|
107
98
|
};
|
|
108
99
|
}
|
|
@@ -95,8 +95,6 @@ function _getPrelude({
|
|
|
95
95
|
requireCycleIgnorePatterns: $ReadOnlyArray<RegExp>,
|
|
96
96
|
...
|
|
97
97
|
}): Module<> {
|
|
98
|
-
const {compile} = require('metro-hermes-compiler');
|
|
99
|
-
|
|
100
98
|
const code = getPreludeCode({
|
|
101
99
|
isDev: dev,
|
|
102
100
|
globalPrefix,
|
|
@@ -118,13 +116,6 @@ function _getPrelude({
|
|
|
118
116
|
map: [],
|
|
119
117
|
},
|
|
120
118
|
},
|
|
121
|
-
{
|
|
122
|
-
type: 'bytecode/script/virtual',
|
|
123
|
-
data: {
|
|
124
|
-
bytecode: compile(code, {sourceURL: '__prelude__.virtual.js'})
|
|
125
|
-
.bytecode,
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
119
|
],
|
|
129
120
|
};
|
|
130
121
|
}
|
|
@@ -21,21 +21,13 @@ const getBoolean = (query, opt, defaultValue) =>
|
|
|
21
21
|
query[opt] == null
|
|
22
22
|
? defaultValue
|
|
23
23
|
: query[opt] === "true" || query[opt] === "1";
|
|
24
|
-
const getNumber = (query, opt, defaultValue) => {
|
|
25
|
-
const number = parseInt(query[opt], 10);
|
|
26
|
-
return Number.isNaN(number) ? defaultValue : number;
|
|
27
|
-
};
|
|
28
24
|
const getBundleType = (bundleType) =>
|
|
29
25
|
bundleType === "map" ? bundleType : "bundle";
|
|
30
26
|
const getTransformProfile = (transformProfile) =>
|
|
31
27
|
transformProfile === "hermes-stable" || transformProfile === "hermes-canary"
|
|
32
28
|
? transformProfile
|
|
33
29
|
: "default";
|
|
34
|
-
module.exports = function parseOptionsFromUrl(
|
|
35
|
-
requestUrl,
|
|
36
|
-
platforms,
|
|
37
|
-
bytecodeVersion
|
|
38
|
-
) {
|
|
30
|
+
module.exports = function parseOptionsFromUrl(requestUrl, platforms) {
|
|
39
31
|
const parsedURL = nullthrows(url.parse(requestUrl, true)); // `true` to parse the query param as an object.
|
|
40
32
|
const query = nullthrows(parsedURL.query);
|
|
41
33
|
const pathname =
|
|
@@ -44,15 +36,8 @@ module.exports = function parseOptionsFromUrl(
|
|
|
44
36
|
const platform =
|
|
45
37
|
query.platform || parsePlatformFilePath(pathname, platforms).platform;
|
|
46
38
|
const bundleType = getBundleType(path.extname(pathname).substr(1));
|
|
47
|
-
const runtimeBytecodeVersion = getNumber(
|
|
48
|
-
query,
|
|
49
|
-
"runtimeBytecodeVersion",
|
|
50
|
-
null
|
|
51
|
-
);
|
|
52
39
|
return {
|
|
53
40
|
bundleType,
|
|
54
|
-
runtimeBytecodeVersion:
|
|
55
|
-
bytecodeVersion === runtimeBytecodeVersion ? bytecodeVersion : null,
|
|
56
41
|
customResolverOptions: parseCustomResolverOptions(parsedURL),
|
|
57
42
|
customTransformOptions: parseCustomTransformOptions(parsedURL),
|
|
58
43
|
dev: getBoolean(query, "dev", true),
|
|
@@ -30,15 +30,6 @@ const getBoolean = (
|
|
|
30
30
|
? defaultValue
|
|
31
31
|
: query[opt] === 'true' || query[opt] === '1';
|
|
32
32
|
|
|
33
|
-
const getNumber = (
|
|
34
|
-
query: $ReadOnly<{[opt: string]: string}>,
|
|
35
|
-
opt: string,
|
|
36
|
-
defaultValue: null,
|
|
37
|
-
) => {
|
|
38
|
-
const number = parseInt(query[opt], 10);
|
|
39
|
-
return Number.isNaN(number) ? defaultValue : number;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
33
|
const getBundleType = (bundleType: string): 'map' | 'bundle' =>
|
|
43
34
|
bundleType === 'map' ? bundleType : 'bundle';
|
|
44
35
|
|
|
@@ -50,7 +41,6 @@ const getTransformProfile = (transformProfile: string): TransformProfile =>
|
|
|
50
41
|
module.exports = function parseOptionsFromUrl(
|
|
51
42
|
requestUrl: string,
|
|
52
43
|
platforms: Set<string>,
|
|
53
|
-
bytecodeVersion: number,
|
|
54
44
|
): BundleOptions {
|
|
55
45
|
const parsedURL = nullthrows(url.parse(requestUrl, true)); // `true` to parse the query param as an object.
|
|
56
46
|
const query = nullthrows(parsedURL.query);
|
|
@@ -60,16 +50,9 @@ module.exports = function parseOptionsFromUrl(
|
|
|
60
50
|
const platform =
|
|
61
51
|
query.platform || parsePlatformFilePath(pathname, platforms).platform;
|
|
62
52
|
const bundleType = getBundleType(path.extname(pathname).substr(1));
|
|
63
|
-
const runtimeBytecodeVersion = getNumber(
|
|
64
|
-
query,
|
|
65
|
-
'runtimeBytecodeVersion',
|
|
66
|
-
null,
|
|
67
|
-
);
|
|
68
53
|
|
|
69
54
|
return {
|
|
70
55
|
bundleType,
|
|
71
|
-
runtimeBytecodeVersion:
|
|
72
|
-
bytecodeVersion === runtimeBytecodeVersion ? bytecodeVersion : null,
|
|
73
56
|
customResolverOptions: parseCustomResolverOptions(parsedURL),
|
|
74
57
|
customTransformOptions: parseCustomTransformOptions(parsedURL),
|
|
75
58
|
dev: getBoolean(query, 'dev', true),
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
12
|
+
|
|
13
|
+
export type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';
|
|
14
|
+
|
|
15
|
+
export interface BundleDetails {
|
|
16
|
+
bundleType: string;
|
|
17
|
+
dev: boolean;
|
|
18
|
+
entryFile: string;
|
|
19
|
+
minify: boolean;
|
|
20
|
+
platform?: string;
|
|
21
|
+
runtimeBytecodeVersion?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A tagged union of all the actions that may happen and we may want to
|
|
26
|
+
* report to the tool user.
|
|
27
|
+
*/
|
|
28
|
+
export type ReportableEvent =
|
|
29
|
+
| {
|
|
30
|
+
port: number;
|
|
31
|
+
hasReducedPerformance: boolean;
|
|
32
|
+
type: 'initialize_started';
|
|
33
|
+
}
|
|
34
|
+
| {
|
|
35
|
+
type: 'initialize_failed';
|
|
36
|
+
port: number;
|
|
37
|
+
error: Error;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
buildID: string;
|
|
41
|
+
type: 'bundle_build_done';
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
buildID: string;
|
|
45
|
+
type: 'bundle_build_failed';
|
|
46
|
+
}
|
|
47
|
+
| {
|
|
48
|
+
buildID: string;
|
|
49
|
+
bundleDetails: BundleDetails;
|
|
50
|
+
type: 'bundle_build_started';
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
error: Error;
|
|
54
|
+
type: 'bundling_error';
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
type: 'dep_graph_loading';
|
|
58
|
+
hasReducedPerformance: boolean;
|
|
59
|
+
}
|
|
60
|
+
| {type: 'dep_graph_loaded'}
|
|
61
|
+
| {
|
|
62
|
+
buildID: string;
|
|
63
|
+
type: 'bundle_transform_progressed';
|
|
64
|
+
transformedFileCount: number;
|
|
65
|
+
totalFileCount: number;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
type: 'global_cache_error';
|
|
69
|
+
error: Error;
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
type: 'global_cache_disabled';
|
|
73
|
+
reason: GlobalCacheDisabledReason;
|
|
74
|
+
}
|
|
75
|
+
| {type: 'transform_cache_reset'}
|
|
76
|
+
| {
|
|
77
|
+
type: 'worker_stdout_chunk';
|
|
78
|
+
chunk: string;
|
|
79
|
+
}
|
|
80
|
+
| {
|
|
81
|
+
type: 'worker_stderr_chunk';
|
|
82
|
+
chunk: string;
|
|
83
|
+
}
|
|
84
|
+
| {
|
|
85
|
+
type: 'hmr_client_error';
|
|
86
|
+
error: Error;
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
type: 'client_log';
|
|
90
|
+
level:
|
|
91
|
+
| 'trace'
|
|
92
|
+
| 'info'
|
|
93
|
+
| 'warn'
|
|
94
|
+
| 'log'
|
|
95
|
+
| 'group'
|
|
96
|
+
| 'groupCollapsed'
|
|
97
|
+
| 'groupEnd'
|
|
98
|
+
| 'debug';
|
|
99
|
+
data: unknown[];
|
|
100
|
+
}
|
|
101
|
+
| {
|
|
102
|
+
type: 'transformer_load_started';
|
|
103
|
+
}
|
|
104
|
+
| {
|
|
105
|
+
type: 'transformer_load_done';
|
|
106
|
+
}
|
|
107
|
+
| {
|
|
108
|
+
type: 'transformer_load_failed';
|
|
109
|
+
error: Error;
|
|
110
|
+
}
|
|
111
|
+
| {
|
|
112
|
+
type: 'watcher_health_check_result';
|
|
113
|
+
result: HealthCheckResult;
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
type: 'watcher_status';
|
|
117
|
+
status: WatcherStatus;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Code across the application takes a reporter as an option and calls the
|
|
122
|
+
* update whenever one of the ReportableEvent happens. Code does not directly
|
|
123
|
+
* write to the standard output, because a build would be:
|
|
124
|
+
*
|
|
125
|
+
* 1. ad-hoc, embedded into another tool, in which case we do not want to
|
|
126
|
+
* pollute that tool's own output. The tool is free to present the
|
|
127
|
+
* warnings/progress we generate any way they want, by specifing a custom
|
|
128
|
+
* reporter.
|
|
129
|
+
* 2. run as a background process from another tool, in which case we want
|
|
130
|
+
* to expose updates in a way that is easily machine-readable, for example
|
|
131
|
+
* a JSON-stream. We don't want to pollute it with textual messages.
|
|
132
|
+
*
|
|
133
|
+
* We centralize terminal reporting into a single place because we want the
|
|
134
|
+
* output to be robust and consistent. The most common reporter is
|
|
135
|
+
* TerminalReporter, that should be the only place in the application should
|
|
136
|
+
* access the `terminal` module (nor the `console`).
|
|
137
|
+
*/
|
|
138
|
+
export interface Reporter {
|
|
139
|
+
update: (event: ReportableEvent) => void;
|
|
140
|
+
}
|
|
@@ -26,7 +26,6 @@ function splitBundleOptions(options) {
|
|
|
26
26
|
hot: options.hot,
|
|
27
27
|
minify: options.minify,
|
|
28
28
|
platform: options.platform,
|
|
29
|
-
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
30
29
|
type: "module",
|
|
31
30
|
unstable_transformProfile: options.unstable_transformProfile,
|
|
32
31
|
},
|
|
@@ -28,7 +28,6 @@ function splitBundleOptions(options: BundleOptions): SplitBundleOptions {
|
|
|
28
28
|
hot: options.hot,
|
|
29
29
|
minify: options.minify,
|
|
30
30
|
platform: options.platform,
|
|
31
|
-
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
32
31
|
type: 'module',
|
|
33
32
|
unstable_transformProfile: options.unstable_transformProfile,
|
|
34
33
|
},
|
|
@@ -116,7 +116,6 @@ function createHasteMap(config, options) {
|
|
|
116
116
|
rootDir: config.projectRoot,
|
|
117
117
|
roots: config.watchFolders,
|
|
118
118
|
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
|
|
119
|
-
unstable_preferTreeFS: config.watcher.unstable_preferTreeFS,
|
|
120
119
|
useWatchman: config.resolver.useWatchman,
|
|
121
120
|
watch: options?.watch == null ? !ci.isCI : options.watch,
|
|
122
121
|
watchmanDeferStates: config.watcher.watchman.deferStates,
|
|
@@ -90,7 +90,6 @@ function createHasteMap(
|
|
|
90
90
|
rootDir: config.projectRoot,
|
|
91
91
|
roots: config.watchFolders,
|
|
92
92
|
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
|
|
93
|
-
unstable_preferTreeFS: config.watcher.unstable_preferTreeFS,
|
|
94
93
|
useWatchman: config.resolver.useWatchman,
|
|
95
94
|
watch: options?.watch == null ? !ci.isCI : options.watch,
|
|
96
95
|
watchmanDeferStates: config.watcher.watchman.deferStates,
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {EventEmitter} from 'events';
|
|
12
|
+
import {ConfigT} from 'metro-config';
|
|
13
|
+
import {ResolverInputOptions} from '../shared/types';
|
|
14
|
+
import {BundlerResolution} from '../DeltaBundler/types';
|
|
15
|
+
|
|
16
|
+
export default class DependencyGraph extends EventEmitter {
|
|
17
|
+
constructor(
|
|
18
|
+
config: ConfigT,
|
|
19
|
+
options?: Readonly<{
|
|
20
|
+
hasReducedPerformance?: boolean;
|
|
21
|
+
watch?: boolean;
|
|
22
|
+
}>,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
ready(): Promise<void>;
|
|
26
|
+
|
|
27
|
+
/** @deprecated Use the constructor + `ready()` directly */
|
|
28
|
+
load(
|
|
29
|
+
config: ConfigT,
|
|
30
|
+
options?: Readonly<{hasReducedPerformance?: boolean; watch?: boolean}>,
|
|
31
|
+
): Promise<DependencyGraph>;
|
|
32
|
+
|
|
33
|
+
getAllFiles(): string[];
|
|
34
|
+
getSha1(filename: string): string;
|
|
35
|
+
getWatcher(): EventEmitter;
|
|
36
|
+
end(): void;
|
|
37
|
+
|
|
38
|
+
/** Given a search context, return a list of file paths matching the query. */
|
|
39
|
+
matchFilesWithContext(
|
|
40
|
+
from: string,
|
|
41
|
+
context: Readonly<{
|
|
42
|
+
/* Should search for files recursively. */
|
|
43
|
+
recursive: boolean;
|
|
44
|
+
/* Filter relative paths against a pattern. */
|
|
45
|
+
filter: RegExp;
|
|
46
|
+
}>,
|
|
47
|
+
): string[];
|
|
48
|
+
|
|
49
|
+
resolveDependency(
|
|
50
|
+
from: string,
|
|
51
|
+
to: string,
|
|
52
|
+
platform: string | null,
|
|
53
|
+
resolverOptions: ResolverInputOptions,
|
|
54
|
+
options: {assumeFlatNodeModules: boolean},
|
|
55
|
+
): BundlerResolution;
|
|
56
|
+
|
|
57
|
+
getHasteName(filePath: string): string;
|
|
58
|
+
getDependencies(filePath: string): string[];
|
|
59
|
+
}
|
|
@@ -52,6 +52,7 @@ function saveAsAssets(bundle, options, log) {
|
|
|
52
52
|
writeMagicFlagFile(modulesDir),
|
|
53
53
|
])
|
|
54
54
|
);
|
|
55
|
+
// $FlowFixMe[unused-promise]
|
|
55
56
|
writeUnbundle.then(() => log("Done writing unbundle output"));
|
|
56
57
|
if (sourcemapOutput) {
|
|
57
58
|
const sourceMap = buildSourcemapWithMetadata({
|
|
@@ -18,6 +18,7 @@ function writeSourcemap(fileName, contents, log) {
|
|
|
18
18
|
}
|
|
19
19
|
log("Writing sourcemap output to:", fileName);
|
|
20
20
|
const writeMap = writeFile(fileName, contents, null);
|
|
21
|
+
// $FlowFixMe[unused-promise]
|
|
21
22
|
writeMap.then(() => log("Done writing sourcemap output"));
|
|
22
23
|
return writeMap;
|
|
23
24
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {OutputOptions, RequestOptions} from '../../shared/types';
|
|
12
|
+
import Server from '../../Server';
|
|
13
|
+
|
|
14
|
+
export function build(
|
|
15
|
+
packagerClient: Server,
|
|
16
|
+
requestOptions: RequestOptions,
|
|
17
|
+
): Promise<{
|
|
18
|
+
code: string;
|
|
19
|
+
map: string;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export function save(
|
|
23
|
+
bundle: {
|
|
24
|
+
code: string;
|
|
25
|
+
map: string;
|
|
26
|
+
},
|
|
27
|
+
options: OutputOptions,
|
|
28
|
+
log: (...args: string[]) => void,
|
|
29
|
+
): Promise<unknown>;
|
|
30
|
+
|
|
31
|
+
export const formatName: string;
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {TransformProfile} from 'metro-babel-transformer';
|
|
12
|
+
import type {CustomResolverOptions} from 'metro-resolver';
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
MetroSourceMapSegmentTuple,
|
|
16
|
+
MixedSourceMap,
|
|
17
|
+
} from 'metro-source-map';
|
|
18
|
+
import type {
|
|
19
|
+
CustomTransformOptions,
|
|
20
|
+
MinifierOptions,
|
|
21
|
+
} from 'metro-transform-worker';
|
|
22
|
+
import type {
|
|
23
|
+
Options as DeltaBundlerOptions,
|
|
24
|
+
TransformInputOptions,
|
|
25
|
+
} from '../DeltaBundler/types';
|
|
26
|
+
|
|
27
|
+
export type BundleType =
|
|
28
|
+
| 'bundle'
|
|
29
|
+
| 'delta'
|
|
30
|
+
| 'meta'
|
|
31
|
+
| 'map'
|
|
32
|
+
| 'ram'
|
|
33
|
+
| 'cli'
|
|
34
|
+
| 'hmr'
|
|
35
|
+
| 'todo'
|
|
36
|
+
| 'graph';
|
|
37
|
+
|
|
38
|
+
type MetroSourceMapOrMappings = MixedSourceMap | MetroSourceMapSegmentTuple[];
|
|
39
|
+
|
|
40
|
+
export interface BundleOptions {
|
|
41
|
+
bundleType: BundleType;
|
|
42
|
+
readonly customResolverOptions: CustomResolverOptions;
|
|
43
|
+
customTransformOptions: CustomTransformOptions;
|
|
44
|
+
dev: boolean;
|
|
45
|
+
entryFile: string;
|
|
46
|
+
readonly excludeSource: boolean;
|
|
47
|
+
readonly hot: boolean;
|
|
48
|
+
readonly inlineSourceMap: boolean;
|
|
49
|
+
minify: boolean;
|
|
50
|
+
readonly modulesOnly: boolean;
|
|
51
|
+
onProgress?: (doneCont: number, totalCount: number) => unknown;
|
|
52
|
+
readonly platform?: string;
|
|
53
|
+
readonly runModule: boolean;
|
|
54
|
+
runtimeBytecodeVersion?: number;
|
|
55
|
+
readonly shallow: boolean;
|
|
56
|
+
sourceMapUrl?: string;
|
|
57
|
+
sourceUrl?: string;
|
|
58
|
+
createModuleIdFactory?: () => (path: string) => number;
|
|
59
|
+
readonly unstable_transformProfile: TransformProfile;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ResolverInputOptions {
|
|
63
|
+
readonly customResolverOptions?: CustomResolverOptions;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface SerializerOptions {
|
|
67
|
+
readonly sourceMapUrl: string | null;
|
|
68
|
+
readonly sourceUrl: string | null;
|
|
69
|
+
readonly runModule: boolean;
|
|
70
|
+
readonly excludeSource: boolean;
|
|
71
|
+
readonly inlineSourceMap: boolean;
|
|
72
|
+
readonly modulesOnly: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface GraphOptions {
|
|
76
|
+
readonly shallow: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Stricter representation of BundleOptions.
|
|
80
|
+
export interface SplitBundleOptions {
|
|
81
|
+
readonly entryFile: string;
|
|
82
|
+
readonly resolverOptions: ResolverInputOptions;
|
|
83
|
+
readonly transformOptions: TransformInputOptions;
|
|
84
|
+
readonly serializerOptions: SerializerOptions;
|
|
85
|
+
readonly graphOptions: GraphOptions;
|
|
86
|
+
readonly onProgress: DeltaBundlerOptions['onProgress'];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ModuleGroups {
|
|
90
|
+
groups: Map<number, Set<number>>;
|
|
91
|
+
modulesById: Map<number, ModuleTransportLike>;
|
|
92
|
+
modulesInGroups: Set<number>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface ModuleTransportLike {
|
|
96
|
+
readonly code: string;
|
|
97
|
+
readonly id: number;
|
|
98
|
+
readonly map: MetroSourceMapOrMappings | null;
|
|
99
|
+
readonly name?: string;
|
|
100
|
+
readonly sourcePath: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ModuleTransportLikeStrict {
|
|
104
|
+
readonly code: string;
|
|
105
|
+
readonly id: number;
|
|
106
|
+
readonly map: MetroSourceMapOrMappings | null;
|
|
107
|
+
readonly name?: string;
|
|
108
|
+
readonly sourcePath: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface RamModuleTransport extends ModuleTransportLikeStrict {
|
|
112
|
+
readonly source: string;
|
|
113
|
+
readonly type: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface OutputOptions {
|
|
117
|
+
bundleOutput: string;
|
|
118
|
+
bundleEncoding?: 'utf8' | 'utf16le' | 'ascii';
|
|
119
|
+
dev?: boolean;
|
|
120
|
+
indexedRamBundle?: boolean;
|
|
121
|
+
platform: string;
|
|
122
|
+
sourcemapOutput?: string;
|
|
123
|
+
sourcemapSourcesRoot?: string;
|
|
124
|
+
sourcemapUseAbsolutePath?: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface RequestOptions {
|
|
128
|
+
entryFile: string;
|
|
129
|
+
inlineSourceMap?: boolean;
|
|
130
|
+
sourceMapUrl?: string;
|
|
131
|
+
dev?: boolean;
|
|
132
|
+
minify: boolean;
|
|
133
|
+
platform: string;
|
|
134
|
+
createModuleIdFactory?: () => (path: string) => number;
|
|
135
|
+
onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type {MinifierOptions};
|
|
@@ -55,7 +55,6 @@ export type BundleOptions = {
|
|
|
55
55
|
onProgress: ?(doneCont: number, totalCount: number) => mixed,
|
|
56
56
|
+platform: ?string,
|
|
57
57
|
+runModule: boolean,
|
|
58
|
-
runtimeBytecodeVersion: ?number,
|
|
59
58
|
+shallow: boolean,
|
|
60
59
|
sourceMapUrl: ?string,
|
|
61
60
|
sourceUrl: ?string,
|
|
@@ -139,6 +138,8 @@ export type RequestOptions = {
|
|
|
139
138
|
platform: string,
|
|
140
139
|
createModuleIdFactory?: () => (path: string) => number,
|
|
141
140
|
onProgress?: (transformedFileCount: number, totalFileCount: number) => void,
|
|
141
|
+
+customResolverOptions?: CustomResolverOptions,
|
|
142
|
+
+customTransformOptions?: CustomTransformOptions,
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
export type {MinifierOptions};
|
package/types/Asset.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface AssetDataWithoutFiles {
|
|
12
|
+
readonly __packager_asset: boolean;
|
|
13
|
+
readonly fileSystemLocation: string;
|
|
14
|
+
readonly hash: string;
|
|
15
|
+
readonly height?: number;
|
|
16
|
+
readonly httpServerLocation: string;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly scales: number[];
|
|
19
|
+
readonly type: string;
|
|
20
|
+
readonly width?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AssetData extends AssetDataWithoutFiles {
|
|
24
|
+
readonly files: string[];
|
|
25
|
+
}
|