-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: switch to module ESNext + moduleResolution bundler #2095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mattzcarey
wants to merge
1
commit into
main
Choose a base branch
from
chore/bundler-tsconfig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| // Auth configuration | ||
| export type { CreateDemoAuthOptions, DemoAuth } from './auth.js'; | ||
| export { createDemoAuth } from './auth.js'; | ||
| export type { CreateDemoAuthOptions, DemoAuth } from './auth'; | ||
| export { createDemoAuth } from './auth'; | ||
|
|
||
| // Auth server setup + demo token verifier (pass to `requireBearerAuth` from @modelcontextprotocol/express) | ||
| export type { SetupAuthServerOptions } from './authServer.js'; | ||
| export { createProtectedResourceMetadataRouter, demoTokenVerifier, getAuth, setupAuthServer } from './authServer.js'; | ||
| export type { SetupAuthServerOptions } from './authServer'; | ||
| export { createProtectedResourceMetadataRouter, demoTokenVerifier, getAuth, setupAuthServer } from './authServer'; |
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
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,4 @@ | |
| * @experimental | ||
| */ | ||
|
|
||
| export * from './tasks/client.js'; | ||
| export * from './tasks/client'; | ||
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 This change flips the two quickstart
tsconfig.jsonfiles toESNext/bundler, butdocs/client-quickstart.md(lines 88–104) anddocs/server-quickstart.md(lines 103–118) still tell users to create a tsconfig with"module": "Node16"/"moduleResolution": "Node16"— those blocks are plain ```json fences (nosource=), so `sync:snippets --check` doesn't catch the drift. Since the quickstarts are user-facing templates that build with plain `tsc` and run the emitted `./build/index.js` directly under Node (no bundler involved), I'd lean toward leaving these two tsconfigs on `Node16`/`NodeNext` and only flipping the shared `common/tsconfig`; otherwise the two doc files need updating to match.Extended reasoning...
What the issue is. This PR changes
examples/client-quickstart/tsconfig.jsonandexamples/server-quickstart/tsconfig.jsonfrom"module": "Node16"/"moduleResolution": "Node16"to"module": "ESNext"/"moduleResolution": "bundler". However, the user-facing quickstart guides that these example projects mirror —docs/client-quickstart.md(the "Create atsconfig.json" block at lines 88–104) anddocs/server-quickstart.md(lines 103–118) — were not updated and still instruct users to write"module": "Node16"/"moduleResolution": "Node16". Before this PR the two example tsconfigs and the two doc snippets were field-for-field identical; after it they diverge onmodule/moduleResolution.Why CI doesn't catch it. Only the
.tscode regions in those docs are auto-synced viasource=-tagged fences; the tsconfig blocks are plain ```json fences with nosource=attribute, so `pnpm sync:snippets --check` (which the PR description lists as passing under `pnpm lint:all`) does not compare them against the example files. This is exactly the case the repo review checklist calls out: "behavior change: check whether docs/**/.md describes the old behavior and needs updating; flag prose that now contradicts the implementation"*.Why
bundleris questionable for these two projects specifically. The PR description justifiesmoduleResolution: bundleron the basis that "tsdown,vitest, and downstream consumers' bundlers" handle resolution. That is true for the published packages, but the quickstarts are different:examples/client-quickstart/package.jsonhas"build": "tsc"and"bin": { "mcp-client-cli": "./build/index.js" }, andexamples/server-quickstart/package.jsonhas"build": "tsc && chmod 755 build/index.js"with"bin": "./build/index.js"and"type": "module". They are compiled with rawtscand the emitted.jsis executed directly by Node — no bundler is involved at any stage. These two tsconfigs were standalone (they don'textendcommon/tsconfig) and were deliberately kept onNode16precisely because they are copy-paste starter templates for end users running under Node.Step-by-step proof.
docs/client-quickstart.md:93–94reads"module": "Node16","moduleResolution": "Node16".examples/client-quickstart/tsconfig.json:5–6reads"module": "ESNext","moduleResolution": "bundler".```json(nosource=…), sosync:snippets --checkignores it.docs/server-quickstart.md:107–108vsexamples/server-quickstart/tsconfig.json:4–5.module/moduleResolution.Impact. Today each quickstart has only a single
src/index.tswith no relative imports, so the example build itself doesn't break, and a user who follows the (stale) docs verbatim still gets a working project. But the docs and examples are now inconsistent, and if a user following the new example config adds a second source file,module: ESNext+moduleResolution: bundlerwill lettscaccept extensionless relative imports and emit them unchanged — which then fail at runtime under Node's ESM loader (ERR_MODULE_NOT_FOUND). TheNode16setting that the docs still recommend is the one that protects against that.How to fix. Two options:
examples/client-quickstart/tsconfig.jsonandexamples/server-quickstart/tsconfig.jsontoNode16/Node16(orNodeNext/NodeNext) and only keep theESNext/bundlerflip incommon/tsconfig/tsconfig.json. The quickstarts are "how a downstream consumer sets up a project," not "how this monorepo builds," so the internal-build rationale doesn't apply to them.tsconfig.jsonblocks indocs/client-quickstart.mdanddocs/server-quickstart.mdto matchESNext/bundler(and consider giving those blocks asource=attribute sosync:snippetscatches future drift).