Skip to content

feat!: migrate fastify-multiple-swagger to ESM#66

Open
inyourtime wants to merge 2 commits into
mainfrom
esm
Open

feat!: migrate fastify-multiple-swagger to ESM#66
inyourtime wants to merge 2 commits into
mainfrom
esm

Conversation

@inyourtime
Copy link
Copy Markdown
Owner

@inyourtime inyourtime commented May 31, 2026

Summary

  • Converted the plugin runtime to native ESM and updated package metadata for ESM exports
  • Reworked internal modules, tests, and type declarations to use ESM imports/exports
  • Preserved the public API, including default and named plugin exports

Testing

  • npm run lint
  • npm test
  • Verified ESM import compatibility with a direct module smoke test

Summary by CodeRabbit

  • Refactor

    • Switched package to native ES modules for improved runtime compatibility.
    • Updated plugin export shape to align with ESM conventions.
    • Reorganized TypeScript declarations to expose options and source types at top level for clearer typing.
  • Chores

    • Migrated tests to ESM syntax.
  • User-facing behavior

    • Default documentation route URLs were adjusted (updated paths for JSON docs).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c32f1d4-0e2d-407f-85b2-02201300e1a7

📥 Commits

Reviewing files that changed from the base of the PR and between 6724ce8 and 773f153.

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

This PR converts the fastify-multiple-swagger package from CommonJS to native ESM. TypeScript type definitions are restructured with top-level exports replacing namespace declarations. All library and test files migrate from require/module.exports to import/export syntax. The package.json declares type: "module" and adds an explicit exports map.

Changes

CommonJS to ESM Module Migration

Layer / File(s) Summary
Type Definition Restructuring
index.d.ts
Type definitions moved from declare namespace to top-level exports; FastifyPluginCallback replaces FastifyPluginAsync and option/document types (FastifyMultipleSwaggerOptions, DocumentSource, ScalarSource, SwaggerUISource, etc.) are exported directly instead of nested under the plugin namespace.
Core Library Module Conversion
index.js, lib/route.js, lib/swagger.js, lib/utils.js
All modules convert from CommonJS (require, module.exports) to ESM (import, export); plugin registration calls updated to use imported bindings (swaggerPlugin, routePlugin) instead of inline require() calls; utility functions (getExposeRouteOptions, getDecoratorName) become named exports.
Package Configuration and Exports Map
package.json
type field set to "module" to declare native ESM support; exports map added with types, import, and default targets for the root entry point.
Test Framework and Type Test Updates
test-types/index.tst.ts, test/hook.test.js, test/scalar.test.js, test/swagger-ui.test.js
Test imports converted to ESM syntax; all tests load the plugin and dependencies via import statements from ../index.js instead of inline require() calls.
Test Suite Plugin Registrations
test/index.test.js
All test cases across 30+ plugin registrations updated to register fastifyMultipleSwagger via the imported binding instead of inline require('..') calls, including validation, routing, configuration, and integration tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 I hopped through modules, swapped require for import,
I nudged the types up to the top, tidy and short,
Tests now say "hello" with import on the run,
package.json gleams under ESM sun,
A little rabbit cheer — the migration is done!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat!: migrate fastify-multiple-swagger to ESM' accurately and concisely summarizes the primary change: converting the codebase from CommonJS to ES modules, as evidenced by changes across all files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch esm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@inyourtime inyourtime changed the title feat: migrate fastify-multiple-swagger to ESM feat!: migrate fastify-multiple-swagger to ESM May 31, 2026
@inyourtime inyourtime added the semver-major Issue or PR that should land as semver major label May 31, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6724ce8f93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-major Issue or PR that should land as semver major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant