Skip to content

fix: add .js extensions to ESM imports - #36

Merged
sv2dev merged 1 commit into
mainfrom
fix/esm-extensions
Mar 31, 2026
Merged

sv2dev merged 1 commit into
mainfrom
fix/esm-extensions

Conversation

@sv2dev

@sv2dev sv2dev commented Mar 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add explicit .js extensions to all relative imports across all packages, fixing Node.js strict ESM resolution (e.g. Playwright workers)
  • Add exports field to all package.json files for proper ESM entry point configuration
  • Bump patch versions: common 0.2.5, core 0.3.1, client 0.2.5, server 0.2.6, typebox 0.1.1

Root cause

moduleResolution: "bundler" + verbatimModuleSyntax: true meant TypeScript accepted extensionless relative imports but passed them through unchanged to the JS output. Node.js strict ESM requires explicit .js extensions, causing ERR_MODULE_NOT_FOUND for consumers.

Test plan

  • bun run --filter '*' build passes
  • bun run --filter '*' test passes (40 tests)
  • bun run --filter '*' typecheck passes
  • Built output verified to contain .js extensions

Summary by CodeRabbit

  • Chores
    • Incremented package versions across client, common, core, server, and typebox packages.
    • Added explicit exports fields to package configurations for improved module resolution with modern package consumers.
    • Updated import paths to use explicit file extensions for enhanced ESM module compatibility.

Node.js strict ESM requires explicit .js extensions in relative imports.
The bundler moduleResolution + verbatimModuleSyntax preserved extensionless
paths in the JS output, breaking consumers using Node.js (e.g. Playwright).
@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3184976-bdde-412a-99f4-9232a65c8e4a

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5a511 and 20d16a8.

📒 Files selected for processing (19)
  • packages/client/package.json
  • packages/client/src/index.ts
  • packages/common/package.json
  • packages/common/src/index.ts
  • packages/core/package.json
  • packages/core/src/audio/audio-processor.ts
  • packages/core/src/images/image-processor.ts
  • packages/core/src/index.ts
  • packages/core/src/util/ffmpeg-processor.ts
  • packages/core/src/videos/video-processor.ts
  • packages/server/package.json
  • packages/server/src/audio/process-audio-handler.ts
  • packages/server/src/images/process-image-handler.ts
  • packages/server/src/index.ts
  • packages/server/src/server.ts
  • packages/server/src/util/request-parsing.ts
  • packages/server/src/util/response.ts
  • packages/server/src/videos/process-video-handler.ts
  • packages/typebox/package.json

Walkthrough

The PR systematically updates import and export paths across all packages to use explicit .js file extensions (ESM-compliant module resolution). Additionally, package.json files are updated with version bumps and new exports fields that explicitly define module entry points.

Changes

Cohort / File(s) Summary
Package Configuration
packages/client/package.json, packages/common/package.json, packages/core/package.json, packages/server/package.json, packages/typebox/package.json
Version increments applied (client 0.2.4→0.2.5, common 0.2.4→0.2.5, core 0.3.0→0.3.1, server 0.2.5→0.2.6, typebox 0.1.0→0.1.1). New exports fields added to client, common, core, and server packages, defining "." entry with types and import targets.
Core Package Exports
packages/core/src/index.ts
Updated all five re-export paths to include explicit .js extensions: audio-processor, images/image-processor, util/ffmpeg-processor, util/mime, videos/video-processor.
Core Package Source Files
packages/core/src/audio/audio-processor.ts, packages/core/src/images/image-processor.ts, packages/core/src/util/ffmpeg-processor.ts, packages/core/src/videos/video-processor.ts
Updated relative import paths to include explicit .js extensions for all module dependencies (e.g., ../util/ffmpeg-processor.js, ../util/streams.js, ../util/mime.js).
Client & Common Package Exports
packages/client/src/index.ts, packages/common/src/index.ts
Updated re-export paths to use explicit .js extensions: client's ./client.js, common's ./mime.js.
Server Package Exports & Utilities
packages/server/src/index.ts, packages/server/src/util/request-parsing.ts, packages/server/src/util/response.ts
Updated import paths to include .js extensions for server.js, typebox.js, and multipart-mixed.js.
Server Package Handlers
packages/server/src/audio/process-audio-handler.ts, packages/server/src/images/process-image-handler.ts, packages/server/src/videos/process-video-handler.ts, packages/server/src/server.ts
Updated all relative imports to include explicit .js extensions for local utility and handler module references.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • refactor: move mimeTypes to @m4k/common #35: Both PRs modify the mimeTypes export in packages/common/src/index.ts; the related PR adds the initial export while this PR updates it to use ESM .js path.
  • Mime-types #32: Both PRs modify core package's mimeTypes export; the related PR adds the export from ./util/mime while this PR updates the path to ./util/mime.js.

Poem

🐰 Extensions explicit, the path is now clear,
With .js appended, no ambiguity here,
Package exports bloom in each manifest's song,
ESM compliance, we've got it all along!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: add .js extensions to ESM imports' directly and accurately summarizes the main change - adding explicit .js extensions to all relative imports across all packages to fix ESM resolution.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/esm-extensions

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.

@sv2dev
sv2dev merged commit 99a9049 into main Mar 31, 2026
2 checks passed
@sv2dev
sv2dev deleted the fix/esm-extensions branch March 31, 2026 13:10
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.

1 participant