Skip to content

fix(postinstall): read the download opt-out from workspace apps in monorepos - #977

Merged
hryhoriiK97 merged 2 commits into
mainfrom
fix/postinstall-workspace-opt-out
Oct 12, 2026
Merged

hryhoriiK97 merged 2 commits into
mainfrom
fix/postinstall-workspace-opt-out

Conversation

@hryhoriiK97

@hryhoriiK97 hryhoriiK97 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The postinstall read the enriched-markdown block only from INIT_CWD/package.json. In a pnpm or yarn workspace that is the repo root, which normally has no block. An app that set "enriched-markdown": { "enableMath": false } in its own package.json still downloaded RaTeX at install time, while the podspec and gradle honoured the same block for the build. The docs told people to put the block in the app's package.json, so in monorepos the download opt-out silently did nothing.

Seen in T3 Code (apps/mobile opts out of math, root has no block).

Change

  • postinstall.mjs reads the block from INIT_CWD as before. When that package.json has no block, it lists workspace members from npm/yarn workspaces and from the packages: list of pnpm-workspace.yaml, keeps the ones that depend on this package, and skips an asset only when every one of them opts out. A root block still wins.
  • The lookup lives inside postinstall.mjs on purpose. Downstream forks pack the postinstall by file name (T3's pack-t3.mjs copies an explicit list), so a sibling module would silently go missing from their tarball and crash the install. A --resolve-config flag prints the lookup result and exits, for tests and debugging.
  • No behaviour change for single apps or roots that already carry the block.
  • Docs: the "Which package.json?" paragraphs describe the fallback, plus a note on pnpm's sideEffectsCache, which reuses postinstall output across projects regardless of the consumer's block.

Tests

Unit (__tests__/consumer-config.test.ts, 13 cases, full suite 103 passing). Each case spawns the real postinstall.mjs --resolve-config against a temp workspace: root block wins over members, pnpm workspace fallback, yarn workspaces array and object forms, mixed opt-outs keep the download, members that do not depend on the package are ignored, no consumers, malformed JSON, glob expansion (*, **, node_modules and dot dirs skipped), negated patterns subtract and cannot veto an opt-out, pnpm YAML with comments, quotes and flow style, peerDependencies consumers, and flag merging that skips non-boolean keys.

End to end with pnpm 11.10.0: packed the library with yarn pack (prepack included), then installed the tarball via file: into two throwaway workspaces shaped like T3's (root without a block, apps/* in pnpm-workspace.yaml, the allowBuilds entry, sideEffectsCache: false so each postinstall really ran).

Workspace apps/mobile block Postinstall log ios/vendor/RaTeX.xcframework grammars
fix enableMath: false math disabled via package.json … skipping RaTeX absent present
control none fetches RaTeX v0.1.14 present present

Also ran the postinstall against a copy of T3 Code's real root package.json, pnpm-workspace.yaml and apps/mobile/package.json: RaTeX is skipped. The branch merges cleanly into fork/t3-mobile (git merge-tree), whose postinstall.mjs is identical to main's.

🤖 Generated with Claude Code

…norepos

The postinstall only read the `enriched-markdown` block from INIT_CWD, which in
a pnpm or yarn workspace is the repo root. An app that set `enableMath: false`
in its own package.json still downloaded RaTeX, while the podspec and gradle
honoured the same block. Fall back to the workspace members that depend on the
package when the root has no block, skipping an asset only when every one of
them opts out. A root block still wins.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hryhoriiK97
hryhoriiK97 force-pushed the fix/postinstall-workspace-opt-out branch from 1b245b2 to b2b056c Compare October 12, 2026 14:02

@eszlamczyk eszlamczyk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall good, the lack of !… (and test asserting behaviour that looks incorrect to me are blockers, everything else is a nitpick (approving though as they will not explode anything but I'd like it addressed)

Comment thread docs-md/BREAKING_CHANGES.md
Comment thread docs/docs/misc/breaking-changes.md Outdated
Comment thread packages/react-native-enriched-markdown/postinstall.mjs Outdated
Comment thread packages/react-native-enriched-markdown/__tests__/consumer-config.test.ts Outdated
Comment thread packages/react-native-enriched-markdown/postinstall.mjs Outdated
Comment thread packages/react-native-enriched-markdown/postinstall.mjs Outdated
Comment thread packages/react-native-enriched-markdown/postinstall.mjs Outdated
Comment thread packages/react-native-enriched-markdown/postinstall.mjs
…d all dependency fields

Review follow-ups: a `!pattern` now subtracts the directories it matches
instead of being skipped, so an excluded package can no longer veto the real
app's opt-out. pnpm-workspace.yaml items keep working with trailing comments,
quotes and the one-line flow form. Any `*ependencies` map counts as consuming
the package, and the merged flags are derived from the consumers' blocks
rather than a fixed list. The old breaking-change entries keep their original
wording with a caution for 1.0.2-1.1.1, and `--resolve-config` is documented
next to the recovery command.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hryhoriiK97
hryhoriiK97 merged commit 9684fdf into main Oct 12, 2026
19 checks passed
@hryhoriiK97
hryhoriiK97 deleted the fix/postinstall-workspace-opt-out branch October 12, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants