From 56c2313bcbf660fe2839dc7720c4616f44c9b46b Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:42:37 +0200 Subject: [PATCH] fix(metro-resolver-symlinks): print Metro path --- .changeset/breezy-dolphins-greet.md | 5 +++++ packages/metro-resolver-symlinks/package.json | 1 + packages/metro-resolver-symlinks/src/utils/patchMetro.ts | 5 ++++- yarn.lock | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/breezy-dolphins-greet.md diff --git a/.changeset/breezy-dolphins-greet.md b/.changeset/breezy-dolphins-greet.md new file mode 100644 index 000000000..b59944282 --- /dev/null +++ b/.changeset/breezy-dolphins-greet.md @@ -0,0 +1,5 @@ +--- +"@rnx-kit/metro-resolver-symlinks": patch +--- + +Print the path to the Metro instance that will be monkey patched if `experimental_retryResolvingFromDisk` is enabled diff --git a/packages/metro-resolver-symlinks/package.json b/packages/metro-resolver-symlinks/package.json index c3a301e7c..8598e1bb4 100644 --- a/packages/metro-resolver-symlinks/package.json +++ b/packages/metro-resolver-symlinks/package.json @@ -22,6 +22,7 @@ "test": "rnx-kit-scripts test" }, "dependencies": { + "@rnx-kit/console": "^1.0.0", "@rnx-kit/tools-node": "^2.0.0", "@rnx-kit/tools-react-native": "^1.3.2", "enhanced-resolve": "^5.8.3" diff --git a/packages/metro-resolver-symlinks/src/utils/patchMetro.ts b/packages/metro-resolver-symlinks/src/utils/patchMetro.ts index 4d7d701b0..1769054cd 100644 --- a/packages/metro-resolver-symlinks/src/utils/patchMetro.ts +++ b/packages/metro-resolver-symlinks/src/utils/patchMetro.ts @@ -1,3 +1,4 @@ +import { info, warn } from "@rnx-kit/console"; import { findMetroPath } from "@rnx-kit/tools-react-native/metro"; import * as fs from "fs"; import * as path from "path"; @@ -40,7 +41,7 @@ export function shouldEnableRetryResolvingFromDisk({ experimental_retryResolvingFromDisk !== "force" && !supportsRetryResolvingFromDisk() ) { - console.warn( + warn( "The version of Metro you're using has not been tested with " + "`experimental_retryResolvingFromDisk`. If you still want to enable " + "it, please set it to 'force'." @@ -83,6 +84,8 @@ export function patchMetro(options: Options): void { return; } + info(`experimental_retryResolvingFromDisk: Patching '${findMetroPath()}'`); + const DependencyGraph = importMetroModule("/src/node-haste/DependencyGraph"); // Patch `_createModuleResolver` and `_doesFileExist` to use `fs.existsSync`. diff --git a/yarn.lock b/yarn.lock index e2a310201..548ef3d39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3787,6 +3787,7 @@ __metadata: version: 0.0.0-use.local resolution: "@rnx-kit/metro-resolver-symlinks@workspace:packages/metro-resolver-symlinks" dependencies: + "@rnx-kit/console": ^1.0.0 "@rnx-kit/eslint-config": "*" "@rnx-kit/scripts": "*" "@rnx-kit/tools-node": ^2.0.0