Fetch wasm plugin compat ranges from swc#317
Conversation
Code Review: Fetch wasm plugin compat ranges from swcOverview: This PR replaces a static committed Bugs / CorrectnessMissing error handling in the cron route — if export async function GET(req: NextRequest) {
if (!isAuthorized(req)) { ... }
try {
const { ranges } = await importWasmPluginCompatRanges();
return NextResponse.json({ ok: true, ranges });
} catch (err) {
console.error("Failed to import compat ranges:", err);
return NextResponse.json({ ok: false, error: String(err) }, { status: 500 });
}
}No stale-range pruning — Import sort order in Security
const secret = process.env.CRON_SECRET;
if (!secret) return process.env.NODE_ENV !== "production"; // dev shortcut
return req.headers.get("authorization") === `Bearer ${secret}`;
Reliability / PerformanceExternal dependency with no fallback or timeout — the Dependency on upstream PR merging — the PR description notes this depends on Prisma batch transaction with sequential upserts — the Code Quality
No tests — the new shared lib ( Summary
The core refactor is well-structured — extracting to a shared lib and using Zod validation for the external data are both good calls. Addressing the error handling and the missing env var documentation would make this production-ready. |
Summary
swc/maininstead of committing a local copy in the plugins app./api/cron/import-ranges.Dependency
Requires the source data file from swc-project/swc#11903 to be merged first.
Validation
pnpm --filter swc-plugins db:buildpnpm --filter swc-plugins build:nextpnpm exec prettier --check apps/plugins/app/import/ranges/page.tsx apps/plugins/app/api/cron/import-ranges/route.ts apps/plugins/lib/import-compat-ranges.ts apps/plugins/vercel.jsonNotes
pnpm --filter swc-plugins exec tsc --noEmit --pretty falsestill fails on the existingcomponents/logo/index.tsx./swc.svgmodule declaration issue.pnpm --filter swc-plugins lintstill fails on the existing Next lint rule loading issue for@next/next/no-html-link-for-pages.