fix(mapper): recognize aliased Express routers#52
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91ed022196
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function expressRouterImportBindingNames(source: string): Set<string> { | ||
| const names = new Set<string>(); | ||
| const pattern = | ||
| /(?:^|[;\n])\s*import\s+(?!type\b)((?:(?!\n\s*import\b)[\s\S]){0,400}?)\bfrom\s*["']express["']/gu; |
There was a problem hiding this comment.
Detect Express imports after inline block comments
The new expressRouterImportBindingNames regex only matches import when it is preceded by start-of-file, ;, or \n, so valid module code like /* banner */ import { Router as R } from 'express' no longer registers R as a Router factory. In that case, const router = R(); router.get(...) routes are silently skipped, which regresses route mapping accuracy for files that keep a header comment on the same line as the first import.
Useful? React with 👍 / 👎.
Summary
ExpressRouter()Tests
./node_modules/.bin/oxfmt src/mappers/node-routes.ts src/mapper.test.ts./node_modules/.bin/vitest run src/mapper.test.ts./node_modules/.bin/tsc -p tsconfig.json --noEmit./node_modules/.bin/oxlint . --config oxlint.jsonFollow-up to review feedback on #47.