Conversation
….cjs export pattern Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add new "Top-Level Script Pattern" section explaining the correct pattern - Show correct pattern: export main but don't call it - Show incorrect pattern: calling await main() in the file - Explain why: bundler injects await main() during inline execution - Update all examples to use correct pattern (module.exports only) - Add clarification to Pattern 2 section about main workflow scripts - Provide real examples from codebase (create_issue.cjs, add_comment.cjs, etc.) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update JavaScript developer instruction for .cjs file
Update JavaScript developer instructions to clarify export pattern for top-level .cjs files
Dec 24, 2025
pelikhan
approved these changes
Dec 24, 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 JavaScript refactoring skill documentation incorrectly showed top-level
.cjsscripts callingawait main()directly. The bundler automatically injects this call during inline execution, so scripts should only exportmain.Changes
Added "Top-Level Script Pattern" section explaining correct pattern with side-by-side comparison:
Updated all code examples in Step 5 and Complete Example sections to use
module.exports = { main }without callingawait main()Added clarification to Pattern 2 (Main Workflow Script) explicitly stating scripts must export but not call
mainDocumented rationale: Bundler injects execution, enables testing by allowing imports without execution, maintains consistency with codebase (
create_issue.cjs,add_comment.cjs, etc.)Context
This pattern enables:
main()with mocks without side effectsawait main()at execution time in GitHub ActionsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.