Fix compute_text.cjs module export and invocation pattern#7445
Merged
Fix compute_text.cjs module export and invocation pattern#7445
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
|
@copilot do not call await main from the script, call main from the action/github-script |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix compute text JavaScript export and invocation
Fix compute_text.cjs module export for bundler compatibility
Dec 23, 2025
…to call main explicitly Per @pelikhan's feedback, the script should export main but not invoke it. The compiler's require() call now properly destructures and invokes main(). Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Fixed in cd25019. The script now exports |
Copilot
AI
changed the title
Fix compute_text.cjs module export for bundler compatibility
Fix compute_text.cjs module export and invocation pattern
Dec 23, 2025
pelikhan
approved these changes
Dec 23, 2025
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
compute_text.cjsscript was missing propermodule.exportsdeclaration and had an incorrect invocation pattern that caused issues when the script was loaded viarequire()in the compiler-generated workflow steps.Changes
pkg/workflow/js/compute_text.cjs: Replacedawait main();withmodule.exports = { main };so the script exports the function without auto-executing itpkg/workflow/compiler_activation_jobs.go: Updated to explicitly destructure and invokemain()when usingrequire()mode:pkg/workflow/js/compute_text.test.cjs: Updated test to match the new export patternThis aligns with the pattern used throughout the codebase for safe output scripts (e.g.,
add_comment.cjs,create_issue.cjs,create_discussion.cjs) and matches the invocation pattern incompiler_safe_outputs_core.go.How It Works
When using
require()mode (with setup action):main:const { main } = require('...');await main();When using inline mode (no setup action):
module.exportsstatements (unnecessary in inline context)This ensures the function is called exactly once in both modes and prevents double execution.
Testing
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.