Skip to content

ref(nitro): Unify pluginPackages, add dashboard route, add includeFiles#148

Draft
dcramer wants to merge 3 commits intomainfrom
dcramer/build/add-explicit-jiti-dep
Draft

ref(nitro): Unify pluginPackages, add dashboard route, add includeFiles#148
dcramer wants to merge 3 commits intomainfrom
dcramer/build/add-explicit-jiti-dep

Conversation

@dcramer
Copy link
Copy Markdown
Member

@dcramer dcramer commented Apr 3, 2026

Three improvements to the Nitro integration:

Unify pluginPackages — Previously had to be declared in both nitro.config.ts and server.ts. Now declare once in juniorNitro() and createApp() resolves it automatically via JUNIOR_PLUGIN_PACKAGES env var (dev) or __junior_config.json (production build).

Diagnostics dashboard — Moved the debug dashboard from the example app's index.html into a core route at GET /api/__junior/dashboard, available in all Junior apps.

includeFiles option — New juniorNitro({ includeFiles: [...] }) option for copying files the bundler can't trace (e.g. dynamically imported pi-ai providers). Resolves packages via import.meta.resolve so it works across pnpm's strict isolation.

dcramer and others added 2 commits April 3, 2026 13:00
Nitro declares jiti as an optional peer dependency for loading
TypeScript config files via c12. Currently it resolves transitively
through vite, but that is fragile. Make it explicit in the init
scaffold and example app.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously pluginPackages had to be declared in both nitro.config.ts
(for build-time file copying) and server.ts (for runtime discovery).
Now declare it once in juniorNitro() and createApp() resolves it
automatically via env var (dev) or config JSON file (production build).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Apr 4, 2026 1:33am

Request Review

Move the debug dashboard from the example app's index.html into a
core route at /api/__junior/dashboard so it's available in all Junior
apps automatically.

Add includeFiles option to juniorNitro() for copying files that the
bundler can't trace (e.g. dynamically imported pi-ai providers).
The example app now uses this to bundle pi-ai provider files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dcramer dcramer changed the title ref(nitro): Unify pluginPackages to single declaration in juniorNitro ref(nitro): Unify pluginPackages, add dashboard route, add includeFiles Apr 4, 2026

const entries = readdirSync(sourceDir);
const re = fileGlob.includes("*")
? new RegExp(`^${fileGlob.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`)
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b81b2bc. Configure here.

/**
* Resolve a package subpath pattern like `@scope/pkg/dist/dir/*.js`
* and copy matching files into the server output under `node_modules/`.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orphaned JSDoc comment attached to wrong function

Low Severity

The JSDoc block on lines 100–103 ("Resolve a package subpath pattern…and copy matching files…") describes copyIncludedFiles (line 125), not resolvePackageDir (line 105). It's stacked directly above a second, correct JSDoc for resolvePackageDir, leaving copyIncludedFiles with no documentation and resolvePackageDir with a misleading extra comment.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b81b2bc. Configure here.

while (dir !== path.dirname(dir)) {
if (path.basename(dir) === lastSeg) return dir;
dir = path.dirname(dir);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directory walk can match wrong inner subdirectory

Low Severity

resolvePackageDir walks up from the resolved entry and returns the first directory whose basename matches the package name's last segment. If the package contains an internal subdirectory with that same name (e.g., a package @scope/lib whose entry resolves through a lib/ subdirectory), the walk finds the inner directory first and returns the wrong path. This would cause copyIncludedFiles to silently copy from (or miss) the wrong location.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b81b2bc. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants