Skip to content

build: add missing exports field - #3

Merged
pi0 merged 2 commits into
pithings:mainfrom
mickaelalvs:export-module
Apr 20, 2026
Merged

pi0 merged 2 commits into
pithings:mainfrom
mickaelalvs:export-module

Conversation

@mickaelalvs

Copy link
Copy Markdown
Contributor

👋🏼 I’m currently working on a Slidev addon based on my article, and I’ve encountered the following issue. I may be overlooking something, so I’d appreciate any feedback if my approach isn’t correct 😊

Problem ❌

The coderaft package currently has no exports, main, or module field in its package.json. This means Node.js and bundlers have no declared entry point for the package.

When a user tries to import coderaft programmatically in a project using a bundler (Vite, esbuild, Rollup, webpack), the tool attempts to resolve the package entry point and fails:

Failed to resolve entry for package "coderaft".
The package may have incorrect main/module/exports specified in its package.json.

This makes import { startCodeServer } from "coderaft", the exact usage shown in the README, seems impossible in any bundler context. Users can only use the CLI (npx coderaft), not the programmatic API.

How ❓

Add an exports field pointing to the existing dist/index.mjs output:

"exports": {
  ".": {
    "types": "./dist/index.d.mts",
    "import": "./dist/index.mjs"
  }
}

Breaking change ❌

This is technically a breaking change for any code importing internal subpaths directly (e.g. import ... from 'coderaft/dist/index.mjs'). With exports defined, only declared subpaths are accessible. However, since the package was not importable at all without this field, the real-world impact is minimal I think 😊

@pi0 pi0 changed the title feat: add exports field to enable programmatic API usage build: add missing exports field Apr 20, 2026
Comment thread lib/package.json Resolved
Co-authored-by: Pooya Parsa <pyapar@gmail.com>

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thnx! I have simplified exports field for better compatibility

@mickaelalvs

Copy link
Copy Markdown
Contributor Author

Thanks ! 😍

@pi0
pi0 merged commit ec7c7bc into pithings:main Apr 20, 2026
1 check failed
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