Repository navigation
fix: CommonJS build fails on import.meta in versionUtils - #47
Merged
Merged
Conversation
Adds versionUtils-cjs.cts, which tshy uses for dist/commonjs in place of versionUtils.ts, reading version.json from __dirname. Same approach as mcp-server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ctufts
previously approved these changes
Oct 23, 2026
ctufts
approved these changes
Oct 26, 2026
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.
The CommonJS build was broken on main:
require('@mapbox/mcp-docs-server/tools')(and/resources,/utils) threwSyntaxError: Cannot use 'import.meta' outside a module.src/utils/versionUtils.tsusesimport.meta.url, and tshy compiled it intodist/commonjsas is.The fix mirrors mcp-server's
src/utils/versionUtils-cjs.cts: tshy swaps inversionUtils-cjs.ctsfor the CommonJS build, and it readsversion.jsonfrom__dirname. The ESM build is unchanged. hosted-mcp-server loads the ESM build, so it was never affected.Testing
origin/mainin a fresh worktree:requireof/toolsand/utilsthrows theimport.metaerror/tools(3 exports),/resourcesand/utilsall load viarequire, andgetVersionInfo()returns0.3.1from both the CJS and ESM buildsnpm test: 85 passing; lint, format and spellcheck cleanHeads up for local builds: a leftover
.tshy-build/from an interrupted build makes tsc skip re-emitting, so a staledistcan hide this either way. Delete it (it's gitignored) before checking.🤖 Generated with Claude Code