feat!: configurable React Router options, native RR middleware, and migration CLI (does not build) - #106
Draft
kevinsalerno wants to merge 1 commit into
Conversation
…ion CLI Addresses reports that Juniper is rigid about React Router configuration. - client/server: add ClientRouterOptions and ServerRouterOptions (basename, future, window, hydrationData, custom createRouter factory) and thread them through createStaticHandler/createStaticRouter for SSR parity. - build: add router config to BuildOptions, injected into generated entrypoints. - middleware: alias MiddlewareFunction to React Router's native MiddlewareFunction and drop the adapter wrapper, so RR middleware works unmodified; _build detects middleware in .ts as well as .tsx. - migrate: new @udibo/juniper/migrate CLI that scans for createBrowserRouter/ createMemoryRouter/createHashRouter route configs, shows findings, and requires confirmation before generating Juniper routes. - middleware/adapters: new @udibo/juniper/middleware/adapters module with Remix loader/action, Express, auth, logging, error and security-header adapters plus composeMiddleware and when. - docs: docs/migration.md, docs/middleware-adapters.md, configuration/routing. Known broken: does not typecheck. See PR description. Generated by MetaCode arm2 as part of an agent evaluation.
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.
Flagging this in the first line so nobody wastes time: this branch fails
deno checkwith 24 errors and its new CLI crashes on import. Details below. I'm opening it deliberately in its broken state as part of an agent evaluation; see Provenance.Summary
Same brief as the companion PR — addressing reports that Juniper is rigid about React Router configuration:
ClientRouterOptionsandServerRouterOptions(basename,future,window,hydrationData, customcreateRouterfactory), threaded throughcreateStaticHandler/createStaticRouter, and exposed viaBuildOptions.routerinto the generated entrypoints.MiddlewareFunctionis aliased directly to React Router's ownMiddlewareFunctionand the adapter wrapper in_client.tsxis removed entirely, so RR middleware works unmodified._buildnow detects middleware in.tsas well as.tsx, enabling isomorphic middleware.@udibo/juniper/migrate) — scans forcreateBrowserRouter/createMemoryRouter/createHashRouterconfigs, reports findings, and requires confirmation before generating routes. Logic split into_migrate.tsbehind a thinmigrate.tsentrypoint, following the existing_-prefix convention.@udibo/juniper/middleware/adapters) — Remix loader/action, Express, auth, logging, error-handler, security-headers,composeMiddleware,when,adaptFunction.Docs: new
docs/migration.mdanddocs/middleware-adapters.md, plus updates toconfiguration.md,middleware.md, androuting.md.Provenance
Written end-to-end by a coding agent (internally: MetaCode arm2) from the same four-prompt sequence as the companion PR, as part of an agent evaluation. Reviewed by a human before submission but not hand-edited or repaired.
What's broken
I verified all of this locally; the agent's own final summary claimed "successfully passes all 24 tests" and "Type-safe — Full TypeScript support," and neither is true. It reached those claims by falling back to
deno test --no-checkafter its typecheck started failing.Blocking
src/migrate.ts:13importsconfirmfrom@std/cli. That export does not exist in@std/cli@1.0.32. The CLI dies at module load —deno run -A src/migrate.ts --helpproduceserror: Unknown export './confirm'and nothing else. The headline deliverable is dead on arrival.src/middleware/adapters.tshas 5 type errors (TS2322, around lines 71, 324, 384, 396) — mostlyPromise<unknown>andResponsenot being assignable toMaybePromise<void | Readonly<RouterContextProvider>>.deno test -P=testaborts withFound 24 errors / Type checking failed. Under--no-checkthe tests do pass (25 passed, 305 steps), which is what the agent reported.CI gates
deno fmt --check— 15 unformatted files.deno lint— 43 problems. Both clean onmain.Design problems worth naming
MiddlewareFunction<Params, Result>declares both generics and then references neither:export type MiddlewareFunction<Params extends AnyParams = AnyParams, Result = unknown> = ReactRouterMiddlewareFunction<RequestContext>;. Any existingMiddlewareFunction<{ id: string }>silently loses its param typing with no compile error — a quiet breaking change.RouteMiddlewareArgswas also rewritten and is now orphaned; nothing references it.v7_*future flags do not exist in React Router 8.3.0 (removed after v7). This branch has 47 occurrences and, worse than merely getting it wrong internally, bakes them into the publicClientRouterOptions.futuretype and documents them indocs/configuration.md. Anyone following those docs sets options that are silently discarded._client.tsxwrapper in favour of a blanket array cast makesnext()mandatory. The agent acknowledged this as an intentional break from Juniper's prior semantics, but it is a real behavioural change for existing middleware.What's actually good here
For balance, since the failures dominate the above: the module layout is the better of the two attempts — splitting
_migrate.tsfrommigrate.tsand namespacing undersrc/middleware/matches this repo's conventions more closely than the companion PR's single flatcli.ts. The adapter set reaches further into the ecosystem (Express, Remix) and the documentation is substantially more thorough. If any of this is interesting, it's the shape rather than the code.Please close this unless the structure is useful to you. It's here as an evaluation artifact and I'd rather it not sit open on your tracker — any reaction at all is more useful to me than a merge.
Testing
deno check— fails, 24 errors.deno test -P=test— never runs, aborts on type checking.deno test --no-check -P=test— 25 passed (305 steps), 0 failed.deno run -A src/migrate.ts --help— fails at module load.src/migrate.test.ts,src/middleware/adapters.test.ts, plus cases insrc/client.test.tsxandsrc/server.test.tsx.BREAKING CHANGE:
MiddlewareFunctionis now an alias for React Router'sMiddlewareFunction<RequestContext>. ItsParamsandResulttype parameters are accepted but ignored, soMiddlewareFunction<{ id: string }>silently loses param typing with no compile error. Callingnext()is now mandatory rather than optional, andRouteMiddlewareArgsis no longer referenced by the middleware type.