Skip to content

Commit

Permalink
pass custom customTransformOptions and customResolverOptions to bundl…
Browse files Browse the repository at this point in the history
…e_build_started log event (facebook#1061)

Summary:
We use `customTransformOptions` in Expo CLI to inform Metro that we're bundling for a Node.js environment (in addition to the `platform=web`), but the logger has no way of indicating to the user that a bundle is Server-specific. This change would enable us to refine the bundling message based on the additional criteria. We can do this if we skip over the server (exports/builds) but it'd be good to have parity. [Example usage](https://github.com/expo/expo/blob/e4eba8a7c9d8134c10578a47d39ddf5294aca9e4/packages/%40expo/cli/src/start/server/metro/MetroTerminalReporter.ts#L227), [corresponding output](https://github.com/expo/expo/blob/e4eba8a7c9d8134c10578a47d39ddf5294aca9e4/packages/%40expo/cli/src/start/server/metro/__tests__/MetroTerminalReporter-test.ts#L61).

Pull Request resolved: facebook#1061

Reviewed By: huntie

Differential Revision: D48454083

Pulled By: robhogan

fbshipit-source-id: 08954b89c9747adfb4db3899ce3f628edbf8e790
  • Loading branch information
EvanBacon authored and facebook-github-bot committed Aug 23, 2023
1 parent bbe1061 commit b2f43ee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/metro/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ class Server {
buildID: getBuildID(buildNumber),
bundleDetails: {
bundleType: bundleOptions.bundleType,
customResolverOptions: bundleOptions.customResolverOptions,
customTransformOptions: bundleOptions.customTransformOptions,
dev: transformOptions.dev,
entryFile: resolvedEntryFilePath,
minify: transformOptions.minify,
Expand Down
2 changes: 2 additions & 0 deletions packages/metro/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ module.exports = (): {
type: 'bundle_build_started',
bundleDetails: {
bundleType: 'Bundle',
customResolverOptions: options.customResolverOptions ?? {},
customTransformOptions: options.customTransformOptions ?? {},
dev: !!options.dev,
entryFile: options.entry,
minify: !!options.minify,
Expand Down
4 changes: 4 additions & 0 deletions packages/metro/src/lib/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

'use strict';

import type {CustomResolverOptions} from 'metro-resolver';
import type {CustomTransformOptions} from 'metro-transform-worker';
import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
import type {Terminal} from 'metro-core';

Expand All @@ -22,6 +24,8 @@ export type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';

export type BundleDetails = {
bundleType: string,
customResolverOptions: CustomResolverOptions,
customTransformOptions: CustomTransformOptions,
dev: boolean,
entryFile: string,
minify: boolean,
Expand Down

0 comments on commit b2f43ee

Please sign in to comment.