Repository navigation
chore(scripts): validate react-native export conditions in yarn constraints - #4370
Open
udit (UditDewan) wants to merge 1 commit into
Open
udit (UditDewan) wants to merge 1 commit into
udit (UditDewan) wants to merge 1 commit into
Conversation
Add a yarn constraint for published packages: - each exports entry's "react-native" condition must point to a file that exists (auto-fixed when only the .ts/.tsx extension is wrong) - packages that peer-depend on react-native must provide a "react-native" condition for every export This catches @fluentui-react-native/tester, whose "react-native" condition pointed at ./src/index.ts while the entry is ./src/index.tsx; fixed via yarn constraints --fix. Part of microsoft#3936
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.
Platforms Impacted
Description of changes
Addresses #3936 by enforcing the
"react-native"export-condition pattern in package.json files.Metro resolves the
react-nativeexport condition to TypeScript source. Nothing validated those targets, and one was already broken:@fluentui-react-native/testerpointedreact-nativeat./src/index.ts, but the entry file is./src/index.tsx. Itsdefaultcondition already uses.tsx.scripts/src/tasks/constrain.tsaddsensureReactNativeExports, run as part ofyarn constraints(and thereforeyarn lint-repo) for every non-private workspace:exportsentry's"react-native"target must exist. If only the.ts/.tsxextension is wrong,yarn constraints --fixcorrects it; otherwise it reports an error.react-nativeinpeerDependenciesmust provide a"react-native"condition on every export. All current RN libraries already comply, so this only guards new packages.desktop-driver,storybook-desktop,scripts) and private apps are not affected.apps/fluent-tester/package.jsongets the fix fromyarn constraints --fix, plus a patch changeset.Verification
yarn constraintsonmainwith the new rule reports exactly one error:@fluentui-react-native/tester: Invalid field exports["."]["react-native"]; expected "./src/index.tsx", found "./src/index.ts". After--fixit is clean.react-nativefrom@fluentui-react-native/menu's exports and adding a bogus./xentry produced both new errors (is missing a "react-native" condition,points to ./src/nope.ts, which does not exist). The edit was reverted afterward.yarn build,yarn lintinscripts,yarn format:check,yarn change:check.yarn knipfails identically onmain(pre-existing unused-dependency findings); this change removes itsapps/fluent-tester"Package entry file not found" hint.react-nativeexport targets are unchecked; tester's points at a missing filePull request checklist
This PR has considered (when applicable):