fix: narrow over-broad default pack exclude patterns#249
Open
adityasingh2400 wants to merge 1 commit into
Open
fix: narrow over-broad default pack exclude patterns#249adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
The default EXCLUDE_PATTERNS dropped real runtime code from packed bundles in two cases: - "*.map" matched any path component ending in ".map", including directories. Packages like es-iterator-helpers ship directories named Iterator.prototype.map/ whose contents are ordinary .js files, so the whole directory was excluded and the bundle crashed at module load. This narrows the pattern to actual source maps (*.js.map, *.cjs.map, *.mjs.map, *.css.map, *.ts.map). - "node_modules/.bin" excluded the CLI shim directory, which some packages reference (for example via existsSync) at module-load time. Removing it from the defaults keeps those shims in the bundle; users who want it gone can add it to their own .mcpbignore. Adds regression tests covering both cases. Fixes modelcontextprotocol#241
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 default EXCLUDE_PATTERNS in
mcpb packdrop real runtime code from the bundle in two cases, so the packed.mcpbinstalls but crashes at module-load time.*.mapmatches any path component ending in.map, including directories. Packages such ases-iterator-helpersship directories namedIterator.prototype.map/andIterator.prototype.flatMap/whose contents are ordinary.jsfiles. The whole directory was excluded while sibling directories (Iterator.prototype.filter/, etc.) were kept, producing aCannot find module .../Iterator.prototype.map/index.jserror at startup. This change narrows the pattern to actual source maps:*.js.map,*.cjs.map,*.mjs.map,*.css.map,*.ts.map.node_modules/.binexcluded all CLI shims. Some packages reference these at module-load time (for example@salesforce/code-analyzer-retirejs-enginecallsfindCommand("retire")at the top level of itsexecutor.js) and throw if the shim is missing. Removing it from the defaults keeps the shims in the bundle. Users who do not want them can still addnode_modules/.binto their own.mcpbignore.node_modules/.cachestays excluded, since it only holds build caches.Testing:
test/mcpbignore.test.tsasserting that source maps are still excluded, that.map-suffixed directories and their files are kept, and thatnode_modules/.binshims are kept. Two of these usegetAllFilesagainst a temp tree that reproduces thees-iterator-helperslayout.yarn build,yarn lint, andyarn testall pass (132 tests).Fixes #241