Skip to content

chore: switch to ESM-only build output#9

Merged
scalvert merged 2 commits into
mainfrom
chore/esm-only-build
Jan 30, 2026
Merged

chore: switch to ESM-only build output#9
scalvert merged 2 commits into
mainfrom
chore/esm-only-build

Conversation

@scalvert

@scalvert scalvert commented Jan 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove CJS build format and switch to ESM-only output
  • Add "type": "module" to package.json for proper ESM support
  • Update all export paths from .mjs to .js extensions
  • Update bin entry for CLI verification script

Test plan

  • Verify npm run build produces only ESM output
  • Test importing the package in an ESM project
  • Verify CLI command docusaurus-mcp-verify works correctly

🤖 Generated with Claude Code

Remove CJS build format and update package configuration to be a pure
ESM module. Update all export paths and bin entries from .mjs to .js
extensions to match the new ESM-only output.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@scalvert scalvert added the bug Something isn't working label Jan 30, 2026
@steve-calvert-glean

Copy link
Copy Markdown
Contributor

Code review

Found 2 issues:

  1. README documentation contains CommonJS examples that will break after ESM-only switch

The README.md contains require() examples for Vercel and Netlify adapters that will fail with "require() of ES Module not supported" after this change adds "type": "module" and removes CJS build output.

const { createVercelHandler } = require('docusaurus-plugin-mcp-server/adapters');
const path = require('path');
module.exports = createVercelHandler({
docsPath: path.join(__dirname, '../build/mcp/docs.json'),
indexPath: path.join(__dirname, '../build/mcp/search-index.json'),
name: 'my-docs',
baseUrl: 'https://docs.example.com',
});
```

  1. Generated adapter files output CommonJS code that will cause runtime failures

The src/adapters/generator.ts generates adapter templates using require() and module.exports for Vercel/Netlify deployments. After this ESM-only switch, users running the generator will get non-functional code that fails at runtime.

const { createVercelHandler } = require('docusaurus-plugin-mcp-server/adapters');
const path = require('path');
const projectRoot = path.join(__dirname, '..');
module.exports = createVercelHandler({
docsPath: path.join(projectRoot, 'build/mcp/docs.json'),
indexPath: path.join(projectRoot, 'build/mcp/search-index.json'),
name: '${name}',
version: '1.0.0',
baseUrl: '${baseUrl}',
});

Both issues require updating to ESM syntax (import/export default) to match the new module format.


🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Update all CommonJS examples to ESM syntax to match the ESM-only
build output:
- README.md: Update Vercel and Netlify adapter examples
- generator.ts: Update generated adapter file templates
- vercel.ts: Update JSDoc example
- netlify.ts: Update JSDoc example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@scalvert scalvert merged commit 50cbad9 into main Jan 30, 2026
8 checks passed
@scalvert scalvert deleted the chore/esm-only-build branch January 30, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants