Uh oh!
There was an error while loading. Please reload this page.
PER-9666: avoid require binding name that breaks the packaged binary - #2306
PER-9666: avoid require binding name that breaks the packaged binary#2306rishigupta1599 wants to merge 4 commits into
require binding name that breaks the packaged binary#2306Conversation
…ed binary
lockfileDiff.js and smartsnap.js bound `const require = createRequire(import.meta.url)`.
When transpiled to CommonJS for the pkg binary, two Babel transforms collide:
preset-env renames the local `require` to `_require` to avoid shadowing CJS's
built-in require, and transform-import-meta expands `import.meta.url` into a
`require('url')...` call whose `require` is then ALSO renamed to `_require`.
The result is `_require(...)` inside its own initializer, so the binary crashes
on load with `TypeError: _require is not a function`.
Rename the binding to `cjsRequire` so the import-meta-emitted `require('url')`
stays the real CJS require. Pure rename; no behavior change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>RaghavsBrowserStack
commented
Jun 19, 2026
Claude Code PR ReviewPR:#2306 • Head:7be2263 • Reviewers: stack:code-reviewer SummaryRenames the Review Table
Findings
Verdict: PASS |
require binding name that breaks the packaged binaryrequire binding name that breaks the packaged binaryShivanshu-07
commented
Jun 19, 2026
Add UTs - Rest LGTM |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
RaghavsBrowserStack
commented
Jun 19, 2026
Claude Code PR ReviewPR:#2306 • Head:1bc95ea • Reviewers: stack:code-reviewer SummaryFixes a Review Table
Findings
Verdict: PASS |
This PR is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This PR was closed because it has been stalled for 28 days with no activity. |
Problem
The packaged
pkgbinary crashes on startup (./percy --version):Root cause
lockfileDiff.jsandsmartsnap.js(both new this release) bind:When these ESM files are transpiled to CommonJS for the binary, two Babel transforms collide:
@babel/preset-envrenames the localrequire→_requireto avoid shadowing CJS's built-inrequire.babel-plugin-transform-import-metaexpandsimport.meta.urlinto arequire('url').pathToFileURL(__filename)...call — and that emittedrequiregets renamed to_requiretoo, because the scope now has a_requirebinding.The transpiled line becomes:
_require('url')runs inside_require's own initializer, while_requireis stillundefined→TypeError: _require is not a function.(No other file hits this —
core/src/api.jsusescreateRequire(url)inline and never binds it to a name calledrequire.)Fix
Rename the binding to
cjsRequirein both files (plus usages). The import-meta-emittedrequire('url')then stays the real CJSrequire, and the transpiled output is correct:Pure rename — no behavior change.
Verification
BABEL_ENV=devCJS transpile, then confirmed the fixed output executes past thecreateRequireline.cli-commandunit specs pass.🤖 Generated with Claude Code