Skip to content

Conversation

@kevmo314
Copy link
Collaborator

Summary

  • Fixed module resolution errors when importing the package in Node.js ESM environments
  • Updated build configuration to properly support both CommonJS and ESM
  • Resolved Rollup v4 compatibility issue with terser plugin

Changes

  • Replaced deprecated rollup-plugin-terser with @rollup/plugin-terser for Rollup v4 compatibility
  • Added three separate build outputs:
    • CommonJS (.js) for Node.js require()
    • ESM (.mjs) for Node.js import statements
    • Browser IIFE (.min.js) for direct script tags
  • Updated package.json exports field with proper conditional exports
  • Fixed TypeScript configuration to only emit declarations (avoiding duplicate JS compilation)

Test plan

  • CommonJS import works: require('@rtirl/api')
  • ESM import works: import * as RealtimeIRL from '@rtirl/api'
  • Browser build loads correctly via script tag
  • TypeScript declarations are properly generated

🤖 Generated with Claude Code

- Replace incompatible rollup-plugin-terser with @rollup/plugin-terser for Rollup v4
- Add separate builds for CommonJS, ESM (.mjs), and browser (IIFE)
- Configure proper package.json exports field for modern module resolution
- Fix TypeScript config to only emit declarations

This fixes module resolution errors when using the package in both Node.js
and browser environments, supporting both require() and import statements.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@github-actions
Copy link

Visit the preview URL for this PR (updated for commit ad86457):

(expires Fri, 22 Aug 2025 14:18:22 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 97736d8937dc1c35fa9cd85e09c8e5539fc44d09

@kevmo314 kevmo314 merged commit 0919317 into main Aug 15, 2025
2 checks passed
@kevmo314 kevmo314 deleted the fix/dual-package-exports branch August 15, 2025 14:20
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.

2 participants