Skip to content

fix: rename hook files to .cjs for ES module compatibility#800

Open
ethan-hurst wants to merge 1 commit intogsd-build:mainfrom
ethan-hurst:fix/esm-hook-compat
Open

fix: rename hook files to .cjs for ES module compatibility#800
ethan-hurst wants to merge 1 commit intogsd-build:mainfrom
ethan-hurst:fix/esm-hook-compat

Conversation

@ethan-hurst
Copy link
Contributor

Summary

  • Fixes ES module compatibility error in startup hook #125 — hooks fail with ReferenceError: require is not defined in projects with "type": "module" in package.json
  • Renames all 3 hook files from .js to .cjs so Node.js always treats them as CommonJS regardless of project module type
  • Adds old .js filenames to orphan cleanup lists so upgrades remove stale hooks and settings references

Changes

  • hooks/gsd-check-update.jshooks/gsd-check-update.cjs
  • hooks/gsd-statusline.jshooks/gsd-statusline.cjs
  • hooks/gsd-context-monitor.jshooks/gsd-context-monitor.cjs
  • bin/install.js — updated hook paths, orphan cleanup, file templating, statusline migration
  • scripts/build-hooks.js — updated copy list
  • docs/context-monitor.md and get-shit-done/workflows/update.md — updated references

Test plan

  • Full regression suite passes (432/432 tests)
  • npm run build:hooks copies .cjs files correctly
  • Install in a project with "type": "module" — verify no require is not defined error on startup
  • Upgrade from previous version — verify old .js hooks are cleaned up

…#125)

Projects with "type": "module" in package.json treat .js files as ES
modules, breaking hooks that use CommonJS require(). Renaming to .cjs
forces Node.js to always treat them as CommonJS regardless of project
module type.

- Rename gsd-check-update.js → .cjs
- Rename gsd-statusline.js → .cjs
- Rename gsd-context-monitor.js → .cjs
- Add old .js filenames to orphan cleanup for upgrades
- Update statusline migration to target .cjs
- Update build script and docs
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.

ES module compatibility error in startup hook

1 participant