Skip to content

fix: rename root index.js to index.cjs for ESM compat - #845

Merged
bradygaster merged 1 commit into
devfrom
squad/fix-insider-esm-return
Apr 5, 2026
Merged

bradygaster merged 1 commit into
devfrom
squad/fix-insider-esm-return

Conversation

@bradygaster

Copy link
Copy Markdown
Collaborator

Problem

Root index.js uses CJS syntax (require, module.exports, module-level return) but root package.json has type:module. Node.js parses .js files as ESM in this configuration, making the bare return; at line 408 an Illegal return statement.

This caused 90/121 tests to fail in the insider release workflow, blocking npm publish.

Fix

  • Rename index.js to index.cjs so Node.js always treats it as CommonJS regardless of type:module
  • Update all 9 test files that reference index.js to use index.cjs

Scope

10 files changed. Purely a file extension rename + test reference updates. No logic changes.


Investigated and fixed by Brady's Squad Bot

Root index.js uses CJS syntax (require, module.exports, module-level
return) but root package.json has type:module, causing Node.js to
parse it as ESM. The bare return; at line 408 triggers SyntaxError:
Illegal return statement, failing 90/121 tests in insider release.

Fix: rename to .cjs so Node always treats it as CommonJS, regardless
of the package type field. Update all 9 test files that reference it.

Fixes insider release workflow run #23997554171.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 5, 2026 08:33
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit bd1c162

⚠️ 2 item(s) to address before review

Status Check Details
✅ Single commit 1 commit — clean history
✅ Not in draft Ready for review
✅ Branch up to date Up to date with dev
❌ Copilot review No Copilot review yet — it may still be processing
✅ Changeset present No source files changed — changeset not required
✅ Scope clean No .squad/ or docs/proposals/ files
✅ No merge conflicts No merge conflicts
✅ Copilot threads resolved No Copilot review threads
❌ CI passing 17 check(s) still running

This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #845

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 10
Files added 0
Files modified 10
Files deleted 0
Modules touched 2

🎯 Risk Factors

  • 10 files changed (6-20 → MEDIUM)
  • 2 modules touched (2-4 → MEDIUM)

📦 Modules Affected

root (1 file)
  • index.cjs
tests (9 files)
  • test/email-scrub.test.cjs
  • test/init-flow.test.cjs
  • test/mcp-config.test.cjs
  • test/migrate-directory.test.cjs
  • test/plugin-marketplace.test.cjs
  • test/rework-rate.test.cjs
  • test/skills-export-import.test.cjs
  • test/version-stamping.test.cjs
  • test/workflows.test.cjs

This report is generated automatically for every PR. See #733 for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the repo-root CLI entry point from index.js to index.cjs so it is always parsed as CommonJS under type: "module", and updates integration tests to execute the renamed file.

Changes:

  • Add index.cjs as the CommonJS CLI entry point (replacing the former index.js usage).
  • Update 9 .cjs integration tests to run index.cjs instead of index.js.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
index.cjs New root CLI entry point using .cjs extension to avoid ESM parsing issues.
test/workflows.test.cjs Points test CLI invocation to index.cjs.
test/version-stamping.test.cjs Points test CLI invocation to index.cjs.
test/skills-export-import.test.cjs Points test CLI invocation to index.cjs.
test/rework-rate.test.cjs Points test CLI invocation to index.cjs.
test/plugin-marketplace.test.cjs Points test CLI invocation to index.cjs.
test/migrate-directory.test.cjs Points test CLI invocation to index.cjs.
test/mcp-config.test.cjs Points test CLI invocation to index.cjs.
test/init-flow.test.cjs Points test CLI invocation to index.cjs.
test/email-scrub.test.cjs Points test CLI invocation to index.cjs.

@bradygaster
bradygaster merged commit 1b1fb08 into dev Apr 5, 2026
22 checks passed
@tamirdresher
tamirdresher deleted the squad/fix-insider-esm-return branch May 7, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants