posit-dev / posit-dev/ai-lib

ai-credentials exports are ESM-only, blocking CommonJS consumers like Positron's extensions/authentication

Open Beginner friendly
#89 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

positron
Dominant language
TypeScript
Stars
5
Forks
2
Avg merge
13h 33m
Merged PRs (30d)
35

Description

Problem

extensions/authentication in Positron can't import from ai-credentials, even though it wants CUSTOM_CLIENT_KIND_AUTH_MAP from ai-credentials/types instead of keeping its own local copy.

Why

extensions/authentication compiles to CommonJS (no "type": "module", module: nodenext). Node resolves a package's CommonJS require() calls using the require condition in that package's exports map. ai-credentials/package.json only defines types and import conditions, no require, so it's ESM-only and can't be loaded from a CommonJS consumer.

For comparison, ai-config (which Positron already depends on) defines both import and require for its exports, which is why that one works fine as a dependency here.

Ask

Add a require condition to ai-credentials's package.json exports map, matching the pattern already used by ai-config, so CommonJS consumers like Positron's extensions/authentication can depend on it directly instead of duplicating its types/constants locally.

Note for whoever picks this up

Double-check there isn't a deliberate reason ai-credentials was kept import-only (e.g. it pulls in something without a safe CJS story) before just copying the ai-config exports shape over.

Reference

posit-dev/positron#15675

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ai-credentials/package.json and compare its exports map with the working pattern in ai-config/package.json. Check whether ai-credentials has any dependency that prevents a CommonJS entry point, then add the matching require condition and verify that Positron's extensions/authentication can import CUSTOM_CLIENT_KIND_AUTH_MAP from ai-credentials/types.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.