feat(compiler): warn on missing export default at build time#581
feat(compiler): warn on missing export default at build time#581lzvxck wants to merge 3 commits into
Conversation
|
@lzvxck is attempting to deploy a commit to the xmcp Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for following up on #560! I think this mostly overlaps with what we already have, though, so I'd love to rescope it before merging. Since PR #528 , the runtime already handles a missing default export, it skips the tool and warns: The same for prompts/resources. So there's no silent crash, and My only concerns with the current approach:
Could you rescope to just the build-time coverage, and lean on the bundler's module graph (instead of a source regex) so detection + messaging stay consistent with classifyToolModule()? Per packages/AGENTS.md that'd also fit better as a compiler-plugin step than a file read in generateCode(). |
|
Thanks for the detailed feedback! Rescoped as requested:
|
|
Perfect @lzvxck! One thing I’m not seeing correctly is that in the description you mention |
Summary
Adds a build-time warning when a tool, resource, or prompt file is missing
export default. Without a default export the runtime destructuresconst { default: handler } = moduleand the server crashes silently when the tool is called. The warning fires insidegenerateCode()— before rspack bundles — so the developer sees it immediately onxmcp devorxmcp build.Only
export defaultis checked.metadataandschemaare intentionally not flagged: the framework defaults both, and omitting them is valid.This is the follow-up to #560. That PR introduced a standalone
xmcp validatecommand; the reviewer (@valebearzotti) pointed out that a separate command was unnecessary and that only the default export check mattered, hooked into the build step. This PR implements exactly that.Type of Change
Affected Packages
xmcp(core framework)create-xmcp-appinit-xmcpContributor Checklist
AGENTS.mdand the scoped rules for the areas I touched.REVIEW_RULES.mdfor logging, timers, config shape, wrappers, compiler/loader changes, and stale examples.Screenshots/Examples
Terminal output with a tool file missing
export default:Related Issues
Closes #560