Skip to content

Remove the remaining type imports that rely on hoisting - #2267

Closed
robhogan wants to merge 1 commit into
robhogan/remove-type-only-edgesfrom
robhogan/no-hoisted-type-imports
Closed

robhogan wants to merge 1 commit into
robhogan/remove-type-only-edgesfrom
robhogan/no-hoisted-type-imports

Conversation

@robhogan

Copy link
Copy Markdown
Collaborator

Follow-up to #2257. Two modules in metro import its own types as metro/private/DeltaBundler/types, and metro-minify-terser's test imports BasicSourceMap from metro-source-map, which the package doesn't depend on. Both resolve only through Yarn's hoisted node_modules, so Flow can't find them under an isolated layout such as pnpm's. Import metro's types relatively, and take the test's map type from the MinifierOptions it already imports.

Changelog: Internal

Test plan:
Under pnpm (with #2110 on top), flow check with the existing name_mapper fails with 3 unresolved imports on #2257 and passes with this. Under Yarn it still passes. jest packages/metro-minify-terser packages/metro/src/ModuleGraph, lint, verify-api-snapshots and typecheck-ts pass.

Follow-up to #2257. Two modules in `metro` import its own types as `metro/private/DeltaBundler/types`, and `metro-minify-terser`'s test imports `BasicSourceMap` from `metro-source-map`, which the package doesn't depend on. Both resolve only through Yarn's hoisted `node_modules`, so Flow can't find them under an isolated layout such as pnpm's. Import `metro`'s types relatively, and take the test's map type from the `MinifierOptions` it already imports.

Changelog: Internal
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 21, 2026
robhogan added a commit that referenced this pull request Nov 21, 2026
Metro is developed with Yarn v1 and `yarn.lock` stays the source of truth, but this lets pnpm users work in the repo by generating a lockfile with `pnpm import`. It adds a `pnpm-workspace.yaml` (pnpm doesn't read `workspaces` from `package.json`), git-ignores the generated `pnpm-lock.yaml` and documents the two commands in the README.

The workspace file also sets two things. `linkWorkspacePackages` - without it, pnpm (since v9) resolves our exact-version internal dependencies like `"metro-core": "0.88.0"` from npm, which fails after a version bump that isn't published yet. `allowBuilds` declines `core-js-pure`'s postinstall (a funding banner) - otherwise pnpm 11+ fails the install with `ERR_PNPM_IGNORED_BUILDS`.

Linking workspace packages gives each one its own `node_modules` pointing at its siblings, where Yarn hoists them. Those links form cycles (`packages/metro-config/node_modules/metro` -> `packages/metro`, whose `node_modules/metro-config` links back), which Flow crawls without hanging since 0.341.0, and with #2257 and #2267 no type imports rely on hoisting, so Flow needs no config changes.

Changelog: Internal

Test plan:
On a fresh clone of this PR, with each of pnpm 11.28.12 and 12.21.0, `pnpm import` then `pnpm install --frozen-lockfile` succeed, `packages/metro/node_modules/metro-core` is a symlink to `../../metro-core`, and `pnpm exec jest --no-watchman packages` passes (167 suites, 3262 tests), as do `build`, `lint`, `format-check`, `verify-api-snapshots`, `typecheck-ts` and `test-smoke`.

`flow check` passes under pnpm 12.15.0 and under Yarn.

Without `allowBuilds`, `pnpm install` exits 1 on both versions.
@robhogan
robhogan added this pull request to stack #2268 November 21, 2026 09:05
@robhogan
robhogan removed this pull request from stack #2268 November 21, 2026 09:07
@robhogan

Copy link
Copy Markdown
Collaborator Author

Folded into #2257.

@robhogan robhogan closed this Nov 21, 2026
@robhogan
robhogan deleted the robhogan/no-hoisted-type-imports branch November 21, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant