fix(producer): shim CJS __dirname / __filename in ESM banner#1445
Closed
ukimsanov wants to merge 1 commit into
Closed
fix(producer): shim CJS __dirname / __filename in ESM banner#1445ukimsanov wants to merge 1 commit into
ukimsanov wants to merge 1 commit into
Conversation
This was referenced Jun 14, 2026
Bundled CJS deps — notably the ffmpeg/Emscripten wasm glue, which does `scriptDirectory = __dirname + "/"` — were crashing at render time with `__dirname is not defined in ES module scope`. The existing banner shimmed `require` from `import.meta.url` but not `__dirname` / `__filename`. Adds both globals from `import.meta.url` alongside the createRequire shim. Verified by re-running a producer render after rebuild — ffmpeg pipeline completes cleanly.
da7b45c to
122b922
Compare
Collaborator
Author
|
Closing — verified the bug only fires when the producer is loaded via Node (Bun is permissive about |
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
Bundled CJS deps — notably the ffmpeg/Emscripten wasm glue, which does
scriptDirectory = __dirname + "/"— were crashing at render time with__dirname is not defined in ES module scope.The existing banner shimmed
requirefromimport.meta.urlbut missed__dirname/__filename. Adds both globals alongside the existingcreateRequireshim.Verification
node packages/producer/build.mjsesbuild bundles complete without errorsSibling PRs in this stack
All three independent; merge order doesn't matter.
Test plan
bun run --filter @hyperframes/producer buildpasses__dirnameerrors