Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/metro-babel-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"license": "MIT",
"dependencies": {
"@babel/core": "^7.25.2",
"@babel/types": "^7.29.8",
"@types/babel__core": "^7.1.14",
"flow-enums-runtime": "^0.0.6",
"flow-parser": "0.336.0",
"metro-cache-key": "0.87.2",
Expand Down
7 changes: 5 additions & 2 deletions packages/metro-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@
},
"license": "MIT",
"dependencies": {
"@types/connect": "^3.4.35",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · Non-hoisted installs still fail on undeclared metro-* imports in metro-config and metro-core

The PR aims to stop published declarations relying on packages that are only available accidentally through transitive dependencies, but the same pattern remains for some internal packages. It isn't a regression, and npm and default pnpm installs aren't affected.

Failure case: a strict TypeScript consumer of metro and metro-config, installed with pnpm hoist: false, gets 4 TS2307 errors at head:

  • metro-config/src/types.d.ts can't find metro-file-map, metro-resolver or metro-transform-worker.
  • metro-core/src/errors/AmbiguousModuleResolutionError.d.ts can't find metro-file-map.

Fix: add these as dependencies of metro-config and metro-core, here or in a follow-up. An import audit of the declarations also flags metro-core to metro, metro-file-map to metro-config and metro-minify-terser to metro-transform-worker. Those would add new links between Metro's packages, so they may need a maintainer decision. They didn't produce errors in this consumer.

Reproduced: Packed head tarballs and installed them in a fresh pnpm 12 consumer with hoist: false. tsc -p . with TypeScript 6.0.3, strict and skipLibCheck: false exited 2 with exactly these 4 TS2307 errors. The same head tarballs pass under default pnpm hoisting. The PR doesn't change these imports or add these dependencies; the failure wasn't run against base. · id 0cfa611c

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added all four direct dependencies in faba463: metro-config now declares metro-file-map, metro-resolver, and metro-transform-worker; metro-core declares metro-file-map. Each uses the existing 0.87.2 workspace version, with no lockfile change.

Freshly built and packed head tarballs reproduce exactly the four TS2307 errors in a strict TypeScript consumer with pnpm hoisting disabled. The same consumer passes with the new manifests; the default-hoisting baseline control also passes. Comparing all 17 tarballs shows only these two package manifests changed.

The config → transform-worker edge stays within the existing config → metro → transform-worker dependency component; the complete strongly connected component partition is unchanged. Other reverse edges noted in the comment remain outside this change.

Validation: frozen Yarn and pnpm installs; full repository checks (162 suites, 3059 tests, 495 snapshots passed; 14 existing skips); and yarn typecheck-ts pass.

"connect": "^3.6.5",
"flow-enums-runtime": "^0.0.6",
"jest-validate": "^29.7.0",
"metro": "0.87.2",
"metro-cache": "0.87.2",
"metro-core": "0.87.2",
"metro-runtime": "0.87.2"
"metro-file-map": "0.87.2",
"metro-resolver": "0.87.2",
"metro-runtime": "0.87.2",
"metro-transform-worker": "0.87.2"
},
"devDependencies": {
"@types/connect": "^3.4.35",
"metro-babel-register": "0.87.2",
"pretty-format": "^29.7.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/metro-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"flow-enums-runtime": "^0.0.6",
"lodash.throttle": "^4.1.1",
"metro-file-map": "0.87.2",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · metro-core gains about 31 installed packages for one type-only import

metro-core imports only the DuplicateHasteCandidatesError type from metro-file-map, in AmbiguousModuleResolutionError.d.ts. Because this is a runtime dependency, standalone installs now also pull in jest-worker, fb-watchman, graceful-fs and others. My previous review suggested this edge, and these measurements weren't available then.

Measured with npm, excluding TypeScript but including the consumer's @types/node:

Install Base Head
metro-core alone 6 packages, 2.8 MB 37 packages, 4.4 MB
metro-cache alone 12 packages, 3.0 MB 41 packages, 4.6 MB

The edge doesn't make a metro-core-only consumer type-clean. It still has 3 TS2307 errors, the same count as base, because the missing metro-file-map error is replaced by metro-file-map being unable to find metro-config. Anyone who also installs metro pays nothing extra for this edge, so the real cost is limited to standalone users.

Fix: consider a small structural type for hasteError in metro-core, or moving that error type into a lower-level package, instead of the dependency. Keeping the edge is reasonable if maintainers consider standalone metro-core and metro-cache installs rare.

Reproduced: compare.sh installs metro-core and metro-cache tarballs from head and base with npm@11 and diffs the lockfile package lists (head-weight.txt, base-weight.txt). metro-core consumer output under npm: 3 TS2307 errors at both base and head. · id 9820579e

"metro-resolver": "0.87.2"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · Consumers of only metro or metro-config still get TS2307 under pnpm hoist: false

The new dependencies fix the metro + metro-config consumer, but declaring both packages directly hides the remaining undeclared imports. TypeScript walks up from the virtual store to the consumer's own node_modules, where it finds metro and metro-config. My previous review said these imports produced no errors; that was only true of this combined consumer.

Failure case: strict consumer, skipLibCheck: false, pnpm hoist: false, importing a single package:

Consumer Base errors Head errors Remaining at head
metro 15 1 metro-file-map/src/flow-types.d.ts can't find metro-config
metro-config 13 2 metro-core/src/Logger.d.ts and metro-resolver/src/types.d.ts can't find metro/private/*
metro-transform-worker 7 2 metro-config and metro/private/*, as above
metro-minify-terser 1 1 can't find metro-transform-worker

This isn't a regression, and every count is the same or lower than base. The PR description already puts these reverse edges out of scope, so a follow-up is fine.

Fix: declaring them would add new cycles to otherwise low-level packages. Moving the shared types down (for example PerfLogger and the types metro-resolver takes from metro/private/DeltaBundler/types) is probably cleaner, and is a maintainer decision.

Reproduced: harness.js packs head and base tarballs. compare.sh runs tsc with TypeScript 6.0.3 on each consumer, after installing with pnpm 12 and hoist: false. Consumers declared @types/node, and the monorepo's node_modules was moved aside so it couldn't satisfy lookups. Head output includes metro: errors 1 TS2307 'metro-config' and metro+config: errors 0. · id 73edff94

},
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions packages/metro-source-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@babel/core": "^7.25.2",
"@babel/traverse": "^7.29.10",
"@babel/types": "^7.29.8",
"@types/babel__core": "^7.1.14",
"flow-enums-runtime": "^0.0.6",
"invariant": "^2.2.4",
"metro-symbolicate": "0.87.2",
Expand Down
1 change: 1 addition & 0 deletions packages/metro-symbolicate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"metro"
],
"dependencies": {
"@types/source-map": "0.5.2",
"flow-enums-runtime": "^0.0.6",
"invariant": "^2.2.4",
"metro-source-map": "0.87.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/metro-transform-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"@babel/generator": "^7.29.1",
"@babel/template": "^7.28.6",
"@babel/traverse": "^7.29.10",
"@babel/types": "^7.29.8",
"@types/babel__core": "^7.1.14",
"@types/babel__traverse": "^7.0.6",
"flow-enums-runtime": "^0.0.6",
"nullthrows": "^1.1.1"
},
Expand All @@ -31,7 +34,6 @@
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@babel/types": "^7.29.8",
"babel-plugin-tester": "^6.0.1",
"metro": "0.87.2"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"@babel/template": "^7.28.6",
"@babel/traverse": "^7.29.10",
"@babel/types": "^7.29.8",
"@types/babel__core": "^7.1.14",
"@types/babel__traverse": "^7.0.6",
"@types/connect": "^3.4.35",
"@types/ws": "^7.4.7",
"@types/yargs": "^17.0.35",
"accepts": "^2.0.0",
"connect": "^3.6.5",
"debug": "^4.4.0",
Expand Down Expand Up @@ -62,8 +67,6 @@
"@babel/plugin-transform-runtime": "^7.24.7",
"@react-native/babel-preset": "0.78.0",
"@react-native/metro-babel-transformer": "0.78.0",
"@types/ws": "^7.4.7",
"@types/yargs": "^17.0.35",
"babel-jest": "^29.7.0",
"dedent": "^0.7.0",
"jest-snapshot": "^29.7.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,11 @@
dependencies:
undici-types "~6.21.0"

"@types/source-map@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@types/source-map/-/source-map-0.5.2.tgz#973459e744cc7445c85b97f770275b479b138e08"
integrity sha512-++w4WmMbk3dS3UeHGzAG+xJOSz5Xqtjys/TBkqG3qp3SeWE7Wwezqe5eB7B51cxUyh4PW7bwVotpsLdBK0D8cw==

"@types/stack-utils@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
Expand Down
Loading