Repository navigation
fix: mark the plugin bundle as ESM so it loads on Node 20.0-20.18 and 22.0-22.6 - #79
Merged
Merged
Conversation
4 of 10 tasks
There was a problem hiding this comment.
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.
Member
Author
|
thanks! |
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.
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 addsplugin/scripts/package.jsonwith"type": "module"so Node always loadsbundle.jsas ESM.plugin/scripts/bundle.jsis an ESM bundle with a.jsextension. In this repository, the rootpackage.json("type": "module") tells Node to treat it as ESM. But the Claude Code plugin cache copies only theplugin/directory (for example~/.claude/plugins/cache/deploygate-marketplace/deploygate/1.5.1/scripts/bundle.js), so nopackage.jsonsits 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 ofplugin/.src/__tests__/plugin.test.ts: assert the file exists and declares"type": "module".The npm package (
@deploygate/mcp) is not affected. It ships the rootpackage.json, andnpm pack --dry-runstill lists onlyLICENSE,README.md,package.jsonandplugin/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
Test plan
npm run buildpassesnpm testpasses (235 tests)I reproduced the plugin cache layout (only
scripts/bundle.js, with nopackage.jsonabove it) and launched it with the exactnode -e "...import(entry)"command fromplugin/.mcp.json:scripts/package.jsonSyntaxError: Cannot use import statement outside a moduleSyntaxErrorSyntaxErrorSyntaxError"Passes" means
scripts/smoke-bundle.mjsfrom #78 (initialize+tools/list, 58 tools). The bundle built from #73 (@modelcontextprotocol/sdk1.32.0,zod4.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
plugin/.codex-plugin/plugin.jsonandplugin/.claude-plugin/plugin.jsonif applicable (handled by release-please)🤖 Generated with Claude Code