fix(packaging): exclude examples from v1 package artifacts#2506
Draft
MustafaKemal0146 wants to merge 1 commit into
Draft
fix(packaging): exclude examples from v1 package artifacts#2506MustafaKemal0146 wants to merge 1 commit into
MustafaKemal0146 wants to merge 1 commit into
Conversation
|
commit: |
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.
Summary
Exclude
src/examples/**from both v1 production TypeScript builds and add package-level regression coverage.The regression test compiles the ESM and CJS production artifacts into a clean temporary package, inspects the result of
npm pack --dry-run, and verifies that:dist/esm/examples/**ordist/cjs/examples/**entry points are published;Root cause
Both
tsconfig.prod.jsonandtsconfig.cjs.jsonincluded all ofsrc/**/*, so repository examples were compiled into the productiondistdirectories. Because the package publishesdistand exposes a"./*"wildcard export, those compiled example paths became importable package subpaths.Some server examples register
processsignal handlers at module scope. Importing one of those accidentally published example entry points could therefore attach aSIGINThandler as an import side effect.Fix
Add
src/examples/**/*to the exclusion lists in both production TypeScript configurations.Excluding the examples at the production-build boundary is safer than changing individual examples: examples remain runnable from source, while no current or future example implementation can accidentally become part of the supported package surface.
Compatibility verification
The packed artifact retains all explicit export targets declared by the v1 package manifest. The regression test also checks these wildcard-backed targets in both ESM and CJS output:
client/stdioserver/stdioshared/protocolValidation
npm ci— passed.npx vitest run test/package-artifacts.test.ts— 1 file passed, 8 tests passed.npx vitest run --exclude "test/e2e/**" --exclude "test/client/stdio.test.ts"— 51 files passed, 1609 tests passed.npm run typecheck— passed.npx eslint src/ test/package-artifacts.test.ts— passed.npx prettier --check test/package-artifacts.test.ts tsconfig.prod.json tsconfig.cjs.json— passed.npm run buildwith Git Bash configured asnpm_config_script_shellon Windows — passed for ESM and CJS.npm pack --dry-run --json --ignore-scriptsagainst the production build — 477 packed files, 0 compiled example paths, 14 verified export targets, 0 missing targets.npm test— 52 test files and 1614 assertions passed, but the command exited non-zero becausetest/client/stdio.test.tsproduced two existing Windows-onlyUnexpected end of JSON inputunhandled errors.npm run lint— ESLint passed; the repository-wide Prettier check reported 219 unchanged files due to CRLF checkout normalization on Windows. Focused formatting checks for all changed files passed.Related work
PR #1939 contains the same production configuration exclusion but does not include package-level regression coverage. This draft keeps the configuration change minimal while proving that published examples are removed and supported SDK subpaths remain intact.
Fixes #817