Skip to content

Add separate Node and Bun entrypoints #1

@mherod

Description

@mherod

Summary

Add explicit Node and Bun entrypoints so the package can expose runtime-appropriate APIs instead of shipping a single Node-oriented build.

Motivation

The package already documents Bun installation in README.md:44-45, but it currently publishes only one ESM entrypoint via main and types in package.json:6-7. The build also emits only src/index.ts today (package.json:13, tsup.config.ts:4-9). Runtime-facing modules import Node APIs directly (src/mdfind.ts:1-3, src/mdls.ts:1-2, plus src/mdutil.ts, src/mdimport.ts, src/live-search.ts, src/query-builder.ts, and src/discover.ts), so there is no dedicated seam for Bun-specific process execution.

Proposed Behavior

  • Expose distinct package entrypoints for Node and Bun, backed by a shared public API surface.
  • Introduce an interop layer that abstracts process execution and stream handling so Node implementations can use node:child_process while Bun entrypoints can use Bun-native APIs where appropriate.
  • Update package exports and build output so consumers can import the correct runtime entrypoint explicitly and TypeScript resolves the matching declarations.
  • Document the supported import paths and runtime expectations.

Acceptance Criteria

  • package.json uses an exports map for runtime-specific entrypoints instead of only main/types.
  • tsup builds separate outputs for the shared surface plus Node/Bun-specific entry files.
  • Command execution is routed through a shared interop boundary rather than importing node:child_process directly in each public module.
  • Public docs and examples show how to import and use the Node and Bun entrypoints.
  • Test coverage verifies both entrypoints expose the intended API surface and execute Spotlight commands correctly on macOS.

Implementation Notes

  • package.json:6-7 and package.json:13 currently publish/build a single dist/index.js output.
  • tsup.config.ts:4-9 defines only one build entry (src/index.ts).
  • src/index.ts:1-36 is a single barrel export today and likely needs sibling runtime entry barrels.
  • src/mdfind.ts:1-3 and src/mdls.ts:1-2 show the current direct Node API dependency pattern that the interop layer should absorb.
  • No similar open issues were found from searches for bun, entrypoint exports, or node bun.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions