Skip to content

Published packages set exports["."].bun to ./src but ship only dist/ — breaks all Bun consumers #23

Description

@amondnet

Summary

Every published service package sets exports["."].bun to a ./src/* entry, but the npm tarballs ship only dist/ ("files": ["dist"]). Because Bun resolves the "bun" export condition first, any Bun consumer that installs these packages from npm fails with Cannot find module. The ./dist/index.js file exists in the tarball but is unreachable, since the exports map declares no subpath for it either.

This affects the whole registry surface, not a single package.

Affected packages (all 0.1.0)

All of the following declare "bun": "./src/index.ts" (or ./src/api.ts) while publishing only dist/:

  • @pleaseai/emulate (bun: ./src/api.ts)
  • @pleaseai/emulate-asana
  • @pleaseai/emulate-autumn
  • @pleaseai/emulate-firebase
  • @pleaseai/emulate-gitlab
  • @pleaseai/emulate-kakao
  • @pleaseai/emulate-linear
  • @pleaseai/emulate-naver
  • @pleaseai/emulate-posthog
  • @pleaseai/emulate-spotify
  • @pleaseai/emulate-supabase
  • @pleaseai/emulate-toss-payments
  • @pleaseai/emulate-workos
  • @pleaseai/emulate-x

Reproduction

mkdir /tmp/repro && cd /tmp/repro && bun init -y
bun add @pleaseai/emulate-asana @emulators/core
echo "import { asanaPlugin } from '@pleaseai/emulate-asana'; console.log(typeof asanaPlugin)" > run.ts
bun run.ts

Actual:

error: Cannot find module '@pleaseai/emulate-asana' from '/tmp/repro/run.ts'

A deep import (@pleaseai/emulate-asana/dist/index.js) also fails, because the exports map exposes no ./dist/* subpath.

Root cause

packages/*/package.json:

{
  "exports": {
    ".": {
      "bun": "./src/index.ts",   // <- not in the published tarball
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  },
  "files": ["dist"]              // <- src/ is never packed
}

Verified against a published tarball — no src/ is present:

$ npm pack @pleaseai/emulate-linear@0.1.0 && tar -tzf pleaseai-emulate-linear-0.1.0.tgz
package/dist/index.d.ts
package/dist/index.js
package/package.json

The "bun" condition is meant to let in-repo development resolve TypeScript source directly, but that path leaks into the published package, where src/ does not exist.

Suggested fixes (any one resolves it)

  1. Point bun at the built output in the published package — e.g. drop the "bun" condition entirely so Bun falls through to "import": "./dist/index.js", or set "bun": "./dist/index.js". Simplest and matches what other conditions already resolve to.
  2. Use publishConfig.exports to override the exports map at publish time (keep ./src for local dev, publish ./dist). This preserves the source-resolution DX in-repo while shipping a correct map.
  3. Ship src/ too — add "src" to files. Works, but bloats the tarball and publishes TS source unnecessarily; options 1/2 are preferable.

Workaround for consumers (until fixed)

Patch the installed exports.bun to the shipped dist. With Bun:

bun patch @pleaseai/emulate-asana@0.1.0
# edit node_modules/@pleaseai/emulate-asana/package.json:
#   "bun": "./src/index.ts"  ->  "bun": "./dist/index.js"
bun patch --commit node_modules/@pleaseai/emulate-asana

Environment

  • Bun 1.3.14
  • @pleaseai/emulate-*@0.1.0, @emulators/core@0.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions