Skip to content

fix: mark the plugin bundle as ESM so it loads on Node 20.0-20.18 and 22.0-22.6 - #79

Merged
satsukies merged 1 commit into
mainfrom
fix/bundle-esm-package-json
Oct 7, 2026
Merged

satsukies merged 1 commit into
mainfrom
fix/bundle-esm-package-json

Conversation

@satsukies

@satsukies satsukies commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

The installed plugin fails to start on Node 20.0–20.18 and 22.0–22.6 with SyntaxError: Cannot use import statement outside a module. This PR adds plugin/scripts/package.json with "type": "module" so Node always loads bundle.js as ESM.

plugin/scripts/bundle.js is an ESM bundle with a .js extension. In this repository, the root package.json ("type": "module") tells Node to treat it as ESM. But the Claude Code plugin cache copies only the plugin/ directory (for example ~/.claude/plugins/cache/deploygate-marketplace/deploygate/1.5.1/scripts/bundle.js), so no package.json sits above the bundle there. Node then falls back to CommonJS unless it has module syntax detection, which is on by default only from 20.19.0 and 22.7.0.

  • plugin/scripts/package.json (new): { "type": "module" }. It sits next to the bundle, so it travels with any copy of plugin/.
  • src/__tests__/plugin.test.ts: assert the file exists and declares "type": "module".

The npm package (@deploygate/mcp) is not affected. It ships the root package.json, and npm pack --dry-run still lists only LICENSE, README.md, package.json and plugin/scripts/bundle.js. No bundle regeneration is needed.

Related Issue

Refs #77 (found while adding the Node 20 compatibility check in #78)

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / internal change
  • Build / CI / tooling

Test plan

  • npm run build passes
  • npm test passes (235 tests)
  • Manually verified the change (describe how below)

I reproduced the plugin cache layout (only scripts/bundle.js, with no package.json above it) and launched it with the exact node -e "...import(entry)" command from plugin/.mcp.json:

Node Without this PR With scripts/package.json
20.0.0 SyntaxError: Cannot use import statement outside a module loads, smoke test passes
20.18.3 SyntaxError passes
20.19.0 loads passes
22.0.0 SyntaxError passes
22.6.0 SyntaxError passes
22.7.0 / 22.12.0 / 24.0.0 loads passes

"Passes" means scripts/smoke-bundle.mjs from #78 (initialize + tools/list, 58 tools). The bundle built from #73 (@modelcontextprotocol/sdk 1.32.0, zod 4.6.5) also passes on Node 20.0.0 with this file in place.

Users get the fix once a release updates the plugin cache. #78 will pin the compatibility job to Node 20.0.0 and run the copied plugin/ directory, so it depends on this PR being merged first.

Checklist

  • I have updated the plugin version in plugin/.codex-plugin/plugin.json and plugin/.claude-plugin/plugin.json if applicable (handled by release-please)
  • I have read and agree to the Code of Conduct

🤖 Generated with Claude Code


Devin Review

Copilot AI balanced review requested due to automatic review settings October 7, 2026 03:46

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused configuration fix correctly addresses isolated plugin installations and includes appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Ensures the standalone plugin bundle loads as ESM on older supported Node.js 20 and 22 releases.

Changes:

  • Adds a local ESM package boundary beside bundle.js.
  • Tests that the bundle directory declares ESM mode.
File Description
plugin/​scripts/​package.json Marks bundled scripts as ESM.
src/​__tests__/​plugin.test.ts Verifies the ESM declaration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@satsukies satsukies self-assigned this Oct 7, 2026

@enomoto-kazuya enomoto-kazuya left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

@satsukies

Copy link
Copy Markdown
Member Author

thanks!

@satsukies
satsukies merged commit 579ba6a into main Oct 7, 2026
5 checks passed
@satsukies
satsukies deleted the fix/bundle-esm-package-json branch October 7, 2026 04:19
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.

3 participants