Repository navigation
fix: make guarded require() calls resolve in the ESM bundle - #17
Merged
Merged
Conversation
added 2 commits
October 18, 2026 01:19
rollup's commonjs plugin leaves require() calls inside try/catch untouched by default (ignoreTryCatch). minimatch@3 loads node's path module that way, so in the ESM output require was undefined, the ReferenceError was swallowed and path.sep fell back to '/'. On Windows this disabled minimatch's separator normalisation, so @actions/glob found nothing, no directory was added to PATH and the action still reported success. Set ignoreTryCatch: false so the guarded requires (node:path, node:crypto, node:http2) become static imports, and assert in CI that the extracted directory actually lands on PATH.
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.
Closes #16
Root cause
dist/index.jsis an ESM bundle, but@rollup/plugin-commonjsleavesrequirecalls insidetry/catchuntouched by default (ignoreTryCatch: true).minimatch@3loads thepathmodule exactly that way:In an ES module
requireis undefined, theReferenceErroris swallowed andpath.sepbecomes'/'. On Windows this disables minimatch's separator normalisation, so@actions/globgets item paths with backslashes that never match the forward-slash pattern,globber.glob()returns nothing, no directory is added toPATH, and the action still reports success.Changes
rollup.config.js:commonjs({ ignoreTryCatch: false })so the guardedrequire()calls are converted to real imports. This also fixes the other silently broken guarded requires (node:crypto,node:http2) that were falling back to theircatchbranches in the ESM bundle..github/workflows/ci.yml: newVerify the extracted directory was added to PATHstep in therunjob, so CI fails if nothing actually lands onPATHinstead of only checking that the action exits 0.dist/index.js+ sourcemap: rebuilt.Verification
minimatch@3: withpath.sep === '/'the patternD:/a/_temp/*/contentdoes not matchD:\a\_temp\guid\content; withpath.sep === '\\'it does.npm test— all 25 tests pass.dist/index.jsagainst the sample zip; it appended the extractedcontentdirectory toGITHUB_PATH.ubuntu-latest,windows-latestandmacos-latestfor each archive type.