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.
Files changed (94) hide show
  1. package/package.json +24 -24
  2. package/src/Asset.d.ts +25 -0
  3. package/src/Bundler.d.ts +39 -0
  4. package/src/DeltaBundler/Graph.d.ts +40 -0
  5. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +18 -0
  6. package/src/DeltaBundler/Transformer.js +1 -2
  7. package/src/DeltaBundler/Transformer.js.flow +1 -2
  8. package/src/DeltaBundler/Worker.d.ts +47 -0
  9. package/src/DeltaBundler/types.d.ts +167 -0
  10. package/src/DeltaBundler.d.ts +58 -0
  11. package/src/HmrServer.js +1 -5
  12. package/src/HmrServer.js.flow +0 -5
  13. package/src/IncrementalBundler.d.ts +97 -0
  14. package/src/IncrementalBundler.js +1 -0
  15. package/src/IncrementalBundler.js.flow +1 -0
  16. package/src/ModuleGraph/worker/collectDependencies.d.ts +27 -0
  17. package/src/ModuleGraph/worker/collectDependencies.js +42 -25
  18. package/src/ModuleGraph/worker/collectDependencies.js.flow +41 -36
  19. package/src/Server/MultipartResponse.d.ts +31 -0
  20. package/src/Server.d.ts +113 -0
  21. package/src/Server.js +11 -133
  22. package/src/Server.js.flow +12 -154
  23. package/src/cli/parseKeyValueParamArray.js +34 -0
  24. package/src/cli/parseKeyValueParamArray.js.flow +31 -0
  25. package/src/cli-utils.js.flow +2 -6
  26. package/src/cli.js +2 -0
  27. package/src/cli.js.flow +1 -0
  28. package/src/commands/build.js +34 -7
  29. package/src/commands/build.js.flow +50 -8
  30. package/src/commands/dependencies.js +11 -9
  31. package/src/commands/dependencies.js.flow +128 -0
  32. package/src/commands/serve.js +11 -4
  33. package/src/commands/serve.js.flow +26 -6
  34. package/src/index.d.ts +151 -0
  35. package/src/index.flow.js +8 -2
  36. package/src/index.flow.js.flow +18 -6
  37. package/src/lib/CountingSet.d.ts +48 -0
  38. package/src/lib/TerminalReporter.d.ts +27 -0
  39. package/src/lib/TerminalReporter.js +1 -4
  40. package/src/lib/TerminalReporter.js.flow +1 -5
  41. package/src/lib/contextModule.d.ts +22 -0
  42. package/src/lib/getGraphId.d.ts +11 -0
  43. package/src/lib/getGraphId.js +0 -1
  44. package/src/lib/getGraphId.js.flow +0 -1
  45. package/src/lib/getPrependedScripts.js +0 -9
  46. package/src/lib/getPrependedScripts.js.flow +0 -9
  47. package/src/lib/parseOptionsFromUrl.js +1 -16
  48. package/src/lib/parseOptionsFromUrl.js.flow +0 -17
  49. package/src/lib/reporting.d.ts +140 -0
  50. package/src/lib/reporting.js.flow +0 -1
  51. package/src/lib/splitBundleOptions.js +0 -1
  52. package/src/lib/splitBundleOptions.js.flow +0 -1
  53. package/src/lib/transformHelpers.js +0 -1
  54. package/src/lib/transformHelpers.js.flow +0 -1
  55. package/src/node-haste/DependencyGraph/createHasteMap.js +0 -1
  56. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +0 -1
  57. package/src/node-haste/DependencyGraph.d.ts +59 -0
  58. package/src/node-haste/DependencyGraph.js +1 -0
  59. package/src/node-haste/DependencyGraph.js.flow +1 -0
  60. package/src/shared/output/RamBundle/as-assets.js +1 -0
  61. package/src/shared/output/RamBundle/as-assets.js.flow +1 -0
  62. package/src/shared/output/RamBundle/write-sourcemap.js +1 -0
  63. package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -0
  64. package/src/shared/output/bundle.d.ts +31 -0
  65. package/src/shared/types.d.ts +138 -0
  66. package/src/shared/types.flow.js.flow +2 -1
  67. package/types/Asset.d.ts +25 -0
  68. package/types/Bundler.d.ts +39 -0
  69. package/types/DeltaBundler/Graph.d.ts +40 -0
  70. package/types/DeltaBundler/Serializers/getRamBundleInfo.d.ts +18 -0
  71. package/types/DeltaBundler/Worker.d.ts +47 -0
  72. package/types/DeltaBundler/types.d.ts +167 -0
  73. package/types/DeltaBundler.d.ts +58 -0
  74. package/types/IncrementalBundler.d.ts +97 -0
  75. package/types/ModuleGraph/worker/collectDependencies.d.ts +27 -0
  76. package/types/Server/MultipartResponse.d.ts +31 -0
  77. package/types/Server.d.ts +113 -0
  78. package/types/index.d.ts +151 -0
  79. package/types/lib/CountingSet.d.ts +48 -0
  80. package/types/lib/TerminalReporter.d.ts +27 -0
  81. package/types/lib/contextModule.d.ts +22 -0
  82. package/types/lib/getGraphId.d.ts +11 -0
  83. package/types/lib/reporting.d.ts +140 -0
  84. package/types/node-haste/DependencyGraph.d.ts +59 -0
  85. package/types/shared/output/bundle.d.ts +31 -0
  86. package/types/shared/types.d.ts +138 -0
  87. package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +0 -81
  88. package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +0 -103
  89. package/src/DeltaBundler/Serializers/helpers/bytecode.js +0 -61
  90. package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +0 -75
  91. package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +0 -40
  92. package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +0 -51
  93. package/src/lib/bundleToBytecode.js +0 -79
  94. package/src/lib/bundleToBytecode.js.flow +0 -97
@@ -0,0 +1,128 @@
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
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ import type {ConfigT} from 'metro-config';
15
+ import typeof Yargs from 'yargs';
16
+ import type {ModuleObject} from 'yargs';
17
+
18
+ const {makeAsyncCommand} = require('../cli-utils');
19
+ const Server = require('../Server');
20
+ const fs = require('fs');
21
+ const {loadConfig} = require('metro-config');
22
+ const path = require('path');
23
+ const {promisify} = require('util');
24
+
25
+ type Args = $ReadOnly<{
26
+ entryFile: string,
27
+ output?: string,
28
+ platform?: string,
29
+ transformer?: string,
30
+ maxWorkers?: number,
31
+ dev: boolean,
32
+ verbose: boolean,
33
+ }>;
34
+
35
+ async function dependencies(args: Args, config: ConfigT) {
36
+ const rootModuleAbsolutePath = args.entryFile;
37
+ if (!fs.existsSync(rootModuleAbsolutePath)) {
38
+ return Promise.reject(
39
+ new Error(`File ${rootModuleAbsolutePath} does not exist`),
40
+ );
41
+ }
42
+
43
+ // $FlowFixMe[cannot-write]
44
+ config.cacheStores = [];
45
+
46
+ const relativePath = path.relative(
47
+ config.server.unstable_serverRoot ?? config.projectRoot,
48
+ rootModuleAbsolutePath,
49
+ );
50
+
51
+ const options = {
52
+ platform: args.platform,
53
+ entryFile: relativePath,
54
+ dev: args.dev,
55
+ minify: false,
56
+ generateSourceMaps: !args.dev,
57
+ };
58
+
59
+ const outStream =
60
+ args.output != null ? fs.createWriteStream(args.output) : process.stdout;
61
+
62
+ const server = new Server(config);
63
+ const deps = await server.getOrderedDependencyPaths(options);
64
+ deps.forEach(modulePath => {
65
+ // Temporary hack to disable listing dependencies not under this directory.
66
+ // Long term, we need either
67
+ // (a) JS code to not depend on anything outside this directory, or
68
+ // (b) Come up with a way to declare this dependency in Buck.
69
+ const isInsideProjectRoots =
70
+ config.watchFolders.filter(root => modulePath.startsWith(root)).length >
71
+ 0;
72
+ if (isInsideProjectRoots) {
73
+ outStream.write(modulePath + '\n');
74
+ }
75
+ });
76
+
77
+ server.end();
78
+ return args.output != null
79
+ ? // $FlowFixMe[method-unbinding]
80
+ promisify(outStream.end).bind(outStream)()
81
+ : Promise.resolve();
82
+ }
83
+
84
+ module.exports = (): {...ModuleObject, handler: Function} => ({
85
+ command: 'get-dependencies [entryFile]',
86
+ desc: 'List all dependencies that will be bundled for a given entry point',
87
+ builder: (yargs: Yargs) => {
88
+ yargs.option('entry-file', {
89
+ type: 'string',
90
+ demandOption: true,
91
+ describe: 'Absolute path to the root JS file',
92
+ });
93
+ yargs.option('output', {
94
+ type: 'string',
95
+ describe:
96
+ 'File name where to store the output, ex. /tmp/dependencies.txt',
97
+ });
98
+ yargs.option('platform', {
99
+ type: 'string',
100
+ describe: 'The platform extension used for selecting modules',
101
+ });
102
+ yargs.option('transformer', {
103
+ type: 'string',
104
+ describe: 'Specify a custom transformer to be used',
105
+ });
106
+ yargs.option('max-workers', {
107
+ type: 'number',
108
+ describe:
109
+ 'Specifies the maximum number of workers the worker-pool ' +
110
+ 'will spawn for transforming files. This defaults to the number of the ' +
111
+ 'cores available on your machine.',
112
+ });
113
+ yargs.option('dev', {
114
+ type: 'boolean',
115
+ default: true,
116
+ describe: 'If false, skip all dev-only code path',
117
+ });
118
+ yargs.option('verbose', {
119
+ type: 'boolean',
120
+ default: false,
121
+ description: 'Enables logging',
122
+ });
123
+ },
124
+ handler: makeAsyncCommand(async (argv: Args) => {
125
+ const config = await loadConfig(argv);
126
+ await dependencies(argv, config);
127
+ }),
128
+ });
@@ -94,12 +94,19 @@ module.exports = () => ({
94
94
 
95
95
  // Inline require() to avoid circular dependency with ../index
96
96
  const MetroApi = require("../index");
97
-
98
- // $FlowExpectedError YargArguments and RunBuildOptions are used interchangeable but their types are not yet compatible
99
- server = await MetroApi.runServer(config, argv);
97
+ const {
98
+ config: _config,
99
+ hmrEnabled: _hmrEnabled,
100
+ maxWorkers: _maxWorkers,
101
+ port: _port,
102
+ projectRoots: _projectRoots,
103
+ resetCache: _resetCache,
104
+ ...runServerOptions
105
+ } = argv;
106
+ server = await MetroApi.runServer(config, runServerOptions);
100
107
  restarting = false;
101
108
  }
102
- const foundConfig = await resolveConfig(argv.config, argv.cwd);
109
+ const foundConfig = await resolveConfig(argv.config);
103
110
  if (foundConfig) {
104
111
  await watchFile(foundConfig.filepath, restart);
105
112
  } else {
@@ -11,8 +11,6 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- import type {RunServerOptions} from '../index';
15
- import type {YargArguments} from 'metro-config/src/configTypes.flow';
16
14
  import typeof Yargs from 'yargs';
17
15
  import type {ModuleObject} from 'yargs';
18
16
 
@@ -20,6 +18,20 @@ const {makeAsyncCommand, watchFile} = require('../cli-utils');
20
18
  const {loadConfig, resolveConfig} = require('metro-config');
21
19
  const {promisify} = require('util');
22
20
 
21
+ type Args = $ReadOnly<{
22
+ projectRoots?: $ReadOnlyArray<string>,
23
+ host: string,
24
+ port: number,
25
+ maxWorkers?: number,
26
+ secure?: boolean,
27
+ secureKey?: string,
28
+ secureCert?: string,
29
+ secureServerOptions?: string,
30
+ hmrEnabled?: boolean,
31
+ config?: string,
32
+ resetCache?: boolean,
33
+ }>;
34
+
23
35
  module.exports = (): {
24
36
  ...ModuleObject,
25
37
  handler: Function,
@@ -63,7 +75,7 @@ module.exports = (): {
63
75
  );
64
76
  },
65
77
 
66
- handler: makeAsyncCommand(async (argv: YargArguments) => {
78
+ handler: makeAsyncCommand(async (argv: Args) => {
67
79
  let server = null;
68
80
  let restarting = false;
69
81
 
@@ -86,13 +98,21 @@ module.exports = (): {
86
98
  // Inline require() to avoid circular dependency with ../index
87
99
  const MetroApi = require('../index');
88
100
 
89
- // $FlowExpectedError YargArguments and RunBuildOptions are used interchangeable but their types are not yet compatible
90
- server = await MetroApi.runServer(config, (argv: RunServerOptions));
101
+ const {
102
+ config: _config,
103
+ hmrEnabled: _hmrEnabled,
104
+ maxWorkers: _maxWorkers,
105
+ port: _port,
106
+ projectRoots: _projectRoots,
107
+ resetCache: _resetCache,
108
+ ...runServerOptions
109
+ } = argv;
110
+ server = await MetroApi.runServer(config, runServerOptions);
91
111
 
92
112
  restarting = false;
93
113
  }
94
114
 
95
- const foundConfig = await resolveConfig(argv.config, argv.cwd);
115
+ const foundConfig = await resolveConfig(argv.config);
96
116
 
97
117
  if (foundConfig) {
98
118
  await watchFile(foundConfig.filepath, restart);
package/src/index.d.ts ADDED
@@ -0,0 +1,151 @@
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 * from './Asset';
12
+ export * from './DeltaBundler/types';
13
+ export * from './ModuleGraph/worker/collectDependencies';
14
+ export * from './Server';
15
+ export * from './lib/reporting';
16
+
17
+ import type {Server as HttpServer} from 'http';
18
+ import type {Server as HttpsServer} from 'https';
19
+ import type {
20
+ ConfigT,
21
+ InputConfigT,
22
+ loadConfig,
23
+ MetroConfig,
24
+ Middleware,
25
+ } from 'metro-config';
26
+ import type {CustomTransformOptions} from 'metro-babel-transformer';
27
+ import type {ReadOnlyGraph} from './DeltaBundler/types';
28
+ import type {Server} from 'ws';
29
+ import Yargs = require('yargs');
30
+ import type {default as MetroServer, ServerOptions} from './Server';
31
+ import type {OutputOptions, RequestOptions} from './shared/types';
32
+
33
+ export {HttpServer, HttpsServer};
34
+
35
+ interface MetroMiddleWare {
36
+ attachHmrServer: (httpServer: HttpServer | HttpsServer) => void;
37
+ end: () => void;
38
+ metroServer: MetroServer;
39
+ middleware: Middleware;
40
+ }
41
+
42
+ export interface RunMetroOptions extends ServerOptions {
43
+ waitForBundler?: boolean;
44
+ }
45
+
46
+ export interface RunServerOptions {
47
+ hasReducedPerformance?: boolean;
48
+ host?: string;
49
+ onError?: (error: Error & {code?: string}) => void;
50
+ onReady?: (server: HttpServer | HttpsServer) => void;
51
+ runInspectorProxy?: boolean;
52
+ secureServerOptions?: Record<string, unknown>;
53
+
54
+ /** @deprecated since version 0.61 */
55
+ secure?: boolean;
56
+
57
+ /** @deprecated since version 0.61 */
58
+ secureCert?: string;
59
+
60
+ /** @deprecated since version 0.61 */
61
+ secureKey?: string;
62
+
63
+ waitForBundler?: boolean;
64
+ watch?: boolean;
65
+ websocketEndpoints?: {
66
+ [path: string]: Server;
67
+ };
68
+ }
69
+
70
+ export interface RunBuildOptions {
71
+ entry: string;
72
+ dev?: boolean;
73
+ out?: string;
74
+ onBegin?: () => void;
75
+ onComplete?: () => void;
76
+ onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
77
+ minify?: boolean;
78
+ output?: {
79
+ build: (
80
+ server: MetroServer,
81
+ options: RequestOptions,
82
+ ) => Promise<{
83
+ code: string;
84
+ map: string;
85
+ }>;
86
+ save: (
87
+ entry: {
88
+ code: string;
89
+ map: string;
90
+ },
91
+ options: OutputOptions,
92
+ postSave: (...args: string[]) => void,
93
+ ) => Promise<unknown>;
94
+ };
95
+ platform?: string;
96
+ sourceMap?: boolean;
97
+ sourceMapUrl?: string;
98
+ }
99
+
100
+ interface BuildGraphOptions {
101
+ entries: ReadonlyArray<string>;
102
+ customTransformOptions?: CustomTransformOptions;
103
+ dev?: boolean;
104
+ minify?: boolean;
105
+ onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
106
+ platform?: string;
107
+ type?: 'module' | 'script';
108
+ }
109
+
110
+ export {MetroConfig};
111
+
112
+ export function runMetro(
113
+ config: InputConfigT,
114
+ options?: RunMetroOptions,
115
+ ): Promise<MetroServer>;
116
+
117
+ export {loadConfig};
118
+
119
+ export function createConnectMiddleWare(
120
+ config: ConfigT,
121
+ options?: RunMetroOptions,
122
+ ): Promise<MetroMiddleWare>;
123
+
124
+ export function runServer(
125
+ config: ConfigT,
126
+ options: RunServerOptions,
127
+ ): Promise<HttpServer | HttpsServer>;
128
+
129
+ export function runBuild(
130
+ config: ConfigT,
131
+ options: RunBuildOptions,
132
+ ): Promise<void>;
133
+
134
+ export function buildGraph(
135
+ config: ConfigT,
136
+ options: BuildGraphOptions,
137
+ ): Promise<ReadOnlyGraph<void>>;
138
+
139
+ type BuildCommandOptions = Record<string, unknown> | null;
140
+ type ServeCommandOptions = Record<string, unknown> | null;
141
+
142
+ interface AttachMetroCLIOptions {
143
+ build?: BuildCommandOptions;
144
+ serve?: ServeCommandOptions;
145
+ dependencies?: unknown;
146
+ }
147
+
148
+ export function attachMetroCli(
149
+ yargs: typeof Yargs,
150
+ options?: AttachMetroCLIOptions,
151
+ ): typeof Yargs;
package/src/index.flow.js CHANGED
@@ -69,6 +69,7 @@ async function runMetro(config, options) {
69
69
  }
70
70
  exports.runMetro = runMetro;
71
71
  exports.loadConfig = loadConfig;
72
+ exports.mergeConfig = mergeConfig;
72
73
  const createConnectMiddleware = async function (config, options) {
73
74
  const metroServer = await runMetro(config, options);
74
75
  let enhancedMiddleware = metroServer.processRequest;
@@ -179,7 +180,8 @@ exports.runServer = async (
179
180
  if (onReady) {
180
181
  onReady(httpServer);
181
182
  }
182
- Object.assign(websocketEndpoints, {
183
+ websocketEndpoints = {
184
+ ...websocketEndpoints,
183
185
  ...(inspectorProxy
184
186
  ? {
185
187
  ...inspectorProxy.createWebSocketListeners(httpServer),
@@ -192,7 +194,7 @@ exports.runServer = async (
192
194
  config
193
195
  ),
194
196
  }),
195
- });
197
+ };
196
198
  httpServer.on("upgrade", (request, socket, head) => {
197
199
  const { pathname } = parse(request.url);
198
200
  if (pathname != null && websocketEndpoints[pathname]) {
@@ -230,6 +232,8 @@ exports.runServer = async (
230
232
  exports.runBuild = async (
231
233
  config,
232
234
  {
235
+ customResolverOptions,
236
+ customTransformOptions,
233
237
  dev = false,
234
238
  entry,
235
239
  onBegin,
@@ -256,6 +260,8 @@ exports.runBuild = async (
256
260
  sourceMapUrl: sourceMap === false ? undefined : sourceMapUrl,
257
261
  createModuleIdFactory: config.serializer.createModuleIdFactory,
258
262
  onProgress,
263
+ customResolverOptions,
264
+ customTransformOptions,
259
265
  };
260
266
  if (onBegin) {
261
267
  onBegin();
@@ -11,6 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ import type {CustomResolverOptions} from 'metro-resolver';
14
15
  import type {ReadOnlyGraph} from './DeltaBundler';
15
16
  import type {ServerOptions} from './Server';
16
17
  import type {OutputOptions, RequestOptions} from './shared/types.flow.js';
@@ -19,6 +20,7 @@ import type {Server as HttpsServer} from 'https';
19
20
  import type {
20
21
  ConfigT,
21
22
  InputConfigT,
23
+ MetroConfig,
22
24
  Middleware,
23
25
  } from 'metro-config/src/configTypes.flow';
24
26
  import type {CustomTransformOptions} from 'metro-transform-worker';
@@ -54,7 +56,7 @@ export type RunMetroOptions = {
54
56
  waitForBundler?: boolean,
55
57
  };
56
58
 
57
- export type RunServerOptions = {
59
+ export type RunServerOptions = $ReadOnly<{
58
60
  hasReducedPerformance?: boolean,
59
61
  host?: string,
60
62
  onError?: (Error & {code?: string}) => void,
@@ -66,10 +68,10 @@ export type RunServerOptions = {
66
68
  secureKey?: string, // deprecated
67
69
  waitForBundler?: boolean,
68
70
  watch?: boolean,
69
- websocketEndpoints?: {
71
+ websocketEndpoints?: $ReadOnly<{
70
72
  [path: string]: typeof ws.Server,
71
- },
72
- };
73
+ }>,
74
+ }>;
73
75
 
74
76
  type BuildGraphOptions = {
75
77
  entries: $ReadOnlyArray<string>,
@@ -112,11 +114,15 @@ export type RunBuildOptions = {
112
114
  platform?: string,
113
115
  sourceMap?: boolean,
114
116
  sourceMapUrl?: string,
117
+ customResolverOptions?: CustomResolverOptions,
118
+ customTransformOptions?: CustomTransformOptions,
115
119
  };
116
120
 
117
121
  type BuildCommandOptions = {} | null;
118
122
  type ServeCommandOptions = {} | null;
119
123
 
124
+ export type {MetroConfig};
125
+
120
126
  async function getConfig(config: InputConfigT): Promise<ConfigT> {
121
127
  const defaultConfig = await getDefaultConfig(config.projectRoot);
122
128
  return mergeConfig(defaultConfig, config);
@@ -167,6 +173,7 @@ async function runMetro(
167
173
 
168
174
  exports.runMetro = runMetro;
169
175
  exports.loadConfig = loadConfig;
176
+ exports.mergeConfig = mergeConfig;
170
177
 
171
178
  const createConnectMiddleware = async function (
172
179
  config: ConfigT,
@@ -291,7 +298,8 @@ exports.runServer = async (
291
298
  onReady(httpServer);
292
299
  }
293
300
 
294
- Object.assign(websocketEndpoints, {
301
+ websocketEndpoints = {
302
+ ...websocketEndpoints,
295
303
  ...(inspectorProxy
296
304
  ? {...inspectorProxy.createWebSocketListeners(httpServer)}
297
305
  : {}),
@@ -302,7 +310,7 @@ exports.runServer = async (
302
310
  config,
303
311
  ),
304
312
  }),
305
- });
313
+ };
306
314
 
307
315
  httpServer.on('upgrade', (request, socket, head) => {
308
316
  const {pathname} = parse(request.url);
@@ -346,6 +354,8 @@ exports.runServer = async (
346
354
  exports.runBuild = async (
347
355
  config: ConfigT,
348
356
  {
357
+ customResolverOptions,
358
+ customTransformOptions,
349
359
  dev = false,
350
360
  entry,
351
361
  onBegin,
@@ -377,6 +387,8 @@ exports.runBuild = async (
377
387
  sourceMapUrl: sourceMap === false ? undefined : sourceMapUrl,
378
388
  createModuleIdFactory: config.serializer.createModuleIdFactory,
379
389
  onProgress,
390
+ customResolverOptions,
391
+ customTransformOptions,
380
392
  };
381
393
 
382
394
  if (onBegin) {
@@ -0,0 +1,48 @@
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 ReadOnlyCountingSet<T> extends Iterable<T> {
12
+ has(item: T): boolean;
13
+ [Symbol.iterator](): Iterator<T>;
14
+ readonly size: number;
15
+ count(item: T): number;
16
+ forEach<ThisT>(
17
+ callbackFn: (
18
+ this: ThisT,
19
+ value: T,
20
+ key: T,
21
+ set: ReadOnlyCountingSet<T>,
22
+ ) => unknown,
23
+ thisArg: ThisT,
24
+ ): void;
25
+ }
26
+
27
+ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
28
+ constructor(items?: Iterable<T>);
29
+ get size(): number;
30
+ has(item: T): boolean;
31
+ add(item: T): void;
32
+ delete(item: T): void;
33
+ keys(): Iterator<T>;
34
+ values(): Iterator<T>;
35
+ [Symbol.iterator](): Iterator<T>;
36
+ count(item: T): number;
37
+ clear(): void;
38
+ forEach<ThisT>(
39
+ callbackFn: (
40
+ this: ThisT,
41
+ value: T,
42
+ key: T,
43
+ set: ReadOnlyCountingSet<T>,
44
+ ) => unknown,
45
+ thisArg: ThisT,
46
+ ): void;
47
+ toJSON(): unknown;
48
+ }
@@ -0,0 +1,27 @@
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 {ReportableEvent} from './reporting';
12
+ import {Terminal} from 'metro-core';
13
+
14
+ export type TerminalReportableEvent =
15
+ | ReportableEvent
16
+ | {
17
+ buildID: string;
18
+ type: 'bundle_transform_progressed_throttled';
19
+ transformedFileCount: number;
20
+ totalFileCount: number;
21
+ };
22
+
23
+ export class TerminalReporter {
24
+ constructor(terminal: Terminal);
25
+ readonly terminal: Terminal;
26
+ update(event: TerminalReportableEvent): void;
27
+ }
@@ -53,7 +53,7 @@ class TerminalReporter {
53
53
  */
54
54
  _getBundleStatusMessage(
55
55
  {
56
- bundleDetails: { entryFile, bundleType, runtimeBytecodeVersion },
56
+ bundleDetails: { entryFile, bundleType },
57
57
  transformedFileCount,
58
58
  totalFileCount,
59
59
  ratio,
@@ -61,9 +61,6 @@ class TerminalReporter {
61
61
  },
62
62
  phase
63
63
  ) {
64
- if (runtimeBytecodeVersion) {
65
- bundleType = "bytecodebundle";
66
- }
67
64
  if (isPrefetch) {
68
65
  bundleType = "PREBUNDLE";
69
66
  }
@@ -101,7 +101,7 @@ class TerminalReporter {
101
101
  */
102
102
  _getBundleStatusMessage(
103
103
  {
104
- bundleDetails: {entryFile, bundleType, runtimeBytecodeVersion},
104
+ bundleDetails: {entryFile, bundleType},
105
105
  transformedFileCount,
106
106
  totalFileCount,
107
107
  ratio,
@@ -109,10 +109,6 @@ class TerminalReporter {
109
109
  }: BundleProgress,
110
110
  phase: BuildPhase,
111
111
  ): string {
112
- if (runtimeBytecodeVersion) {
113
- bundleType = 'bytecodebundle';
114
- }
115
-
116
112
  if (isPrefetch) {
117
113
  bundleType = 'PREBUNDLE';
118
114
  }
@@ -0,0 +1,22 @@
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 {ContextMode} from '../ModuleGraph/worker/collectDependencies';
12
+
13
+ export interface RequireContext {
14
+ /* Should search for files recursively. Optional, default `true` when `require.context` is used */
15
+ readonly recursive: boolean;
16
+ /* Filename filter pattern for use in `require.context`. Optional, default `.*` (any file) when `require.context` is used */
17
+ readonly filter: RegExp;
18
+ /** Mode for resolving dynamic dependencies. Defaults to `sync` */
19
+ readonly mode: ContextMode;
20
+ /** Absolute path of the directory to search in */
21
+ readonly from: string;
22
+ }
@@ -0,0 +1,11 @@
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 type GraphId = string;
@@ -34,7 +34,6 @@ function getGraphId(
34
34
  minify: options.minify,
35
35
  unstable_disableES6Transforms: options.unstable_disableES6Transforms,
36
36
  platform: options.platform != null ? options.platform : null,
37
- runtimeBytecodeVersion: options.runtimeBytecodeVersion,
38
37
  type: options.type,
39
38
  experimentalImportBundleSupport,
40
39
  unstable_allowRequireContext,
@@ -45,7 +45,6 @@ function getGraphId(
45
45
  minify: options.minify,
46
46
  unstable_disableES6Transforms: options.unstable_disableES6Transforms,
47
47
  platform: options.platform != null ? options.platform : null,
48
- runtimeBytecodeVersion: options.runtimeBytecodeVersion,
49
48
  type: options.type,
50
49
  experimentalImportBundleSupport,
51
50
  unstable_allowRequireContext,