Repository navigation
fix(postinstall): read the download opt-out from workspace apps in monorepos - #977
Merged
Merged
Conversation
…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
force-pushed
the
fix/postinstall-workspace-opt-out
branch
from
October 12, 2026 14:02
1b245b2 to
b2b056c
Compare
eszlamczyk
approved these changes
Oct 12, 2026
eszlamczyk
left a comment
Collaborator
There was a problem hiding this comment.
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)
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The postinstall read the
enriched-markdownblock only fromINIT_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 ownpackage.jsonstill 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'spackage.json, so in monorepos the download opt-out silently did nothing.Seen in T3 Code (
apps/mobileopts out of math, root has no block).Change
postinstall.mjsreads the block fromINIT_CWDas before. When thatpackage.jsonhas no block, it lists workspace members from npm/yarnworkspacesand from thepackages:list ofpnpm-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.postinstall.mjson purpose. Downstream forks pack the postinstall by file name (T3'spack-t3.mjscopies an explicit list), so a sibling module would silently go missing from their tarball and crash the install. A--resolve-configflag prints the lookup result and exits, for tests and debugging.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 realpostinstall.mjs --resolve-configagainst a temp workspace: root block wins over members, pnpm workspace fallback, yarnworkspacesarray 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_modulesand dot dirs skipped), negated patterns subtract and cannot veto an opt-out, pnpm YAML with comments, quotes and flow style,peerDependenciesconsumers, 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 viafile:into two throwaway workspaces shaped like T3's (root without a block,apps/*inpnpm-workspace.yaml, theallowBuildsentry,sideEffectsCache: falseso each postinstall really ran).apps/mobileblockios/vendor/RaTeX.xcframeworkenableMath: falsemath disabled via package.json … skipping RaTeXAlso ran the postinstall against a copy of T3 Code's real root
package.json,pnpm-workspace.yamlandapps/mobile/package.json: RaTeX is skipped. The branch merges cleanly intofork/t3-mobile(git merge-tree), whosepostinstall.mjsis identical to main's.🤖 Generated with Claude Code