feat(detection): add alternatePackageNames so React Router v6 is detected - #1001
Open
Ref34t wants to merge 1 commit into
Open
feat(detection): add alternatePackageNames so React Router v6 is detected#1001Ref34t wants to merge 1 commit into
Ref34t wants to merge 1 commit into
Conversation
…cted React Router v6 ships the router as `react-router-dom`; v7 consolidated onto `react-router`. The detection gate only checked `react-router`, so v6 projects declared only as `react-router-dom` never matched and fell through to the javascript_web fallback. The rest of the config already assumes v6 works: `minimumVersion` is '6.0.0' and `getReactRouterMode` has an explicit V6 branch, but neither was reachable because detection ran first. context-mill's dedicated `react-react-router-6` skill variant was unreachable for the same reason. Adds an optional `alternatePackageNames` to FrameworkDetection rather than special-casing react-router in the runner, and uses both names in detect, getVersion, getInstalledVersion, and the is-it-installed warning. Verified against context-mill's example apps by running every framework predicate over each one: react-react-router-6 resolved to javascript_web before and react-router after, with the three v7 variants unchanged.
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.
Why
React Router v6 ships the router as
react-router-dom; v7 consolidated ontoreact-router. The detection gate only checked the v7 name:hasDeclaredDependencyis an exact key lookup, so a v6 project — which declares onlyreact-router-dom— never matched, and first-match detection carried it through to thejavascript_webfallback.The rest of the config already assumes v6 is supported:
minimumVersionis'6.0.0', andgetReactRouterModein./utilschecks both package names and has an explicitV6branch. Neither is reachable, because detection fails first. context-mill's dedicatedreact-react-router-6skill variant is unreachable for the same reason, so a v6 project gets the genericjavascript_webrules — whose pageview guidance is written for "SPAs without a framework router".What this adds
An optional
alternatePackageNamesonFrameworkDetection, rather than special-casing React Router in the runner — following the guidance in.claude/skills/wizard-development: "the interface is missing a field — extend the interface, don't add special-case logic to the runner."React Router declares
['react-router-dom']there, and both names are now used indetect,getVersion,getInstalledVersion, and the is-it-installed warning inposthog-integration.Test plan
src/lib/detection/__tests__/framework.test.ts: a v6 project (react-router-domonly) and a v7 project both resolve toIntegration.reactRouter.pnpm build && vitest run— 1558 tests pass across 113 files.tsc --noEmit— 27 pre-existing errors before and after, none in the touched files.detect()predicate over each app incontext-mill/example-apps:react-react-router-6resolved tojavascript_webbefore andreact-routerafter.react-react-router-7-data,-declarativeand-frameworkare unchanged, and no other app's result moved.