Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for ES Module Support in @atproto/api #2175

Open
ShinoharaTa opened this issue Feb 13, 2024 · 1 comment
Open

Request for ES Module Support in @atproto/api #2175

ShinoharaTa opened this issue Feb 13, 2024 · 1 comment

Comments

@ShinoharaTa
Copy link

Dear Bluesky maintainers,

I am currently integrating the @atproto/api library into a TypeScript project that utilizes ES modules. Upon attempting to compile my project with TypeScript (tsc), I encountered the following error:

SyntaxError: Named export 'BskyAgent' not found. The requested module '@atproto/api' is a CommonJS module, which may not support all module.exports as named exports.

This issue arises because the library is distributed as a CommonJS module, which complicates direct usage with named imports in ES module environments.

Expected Behavior
Ideally, I would like to import the @atproto/api components using ES module syntax directly in TypeScript without encountering compatibility issues or errors. For example:

import { BskyAgent, RichText } from "@atproto/api";

Proposed Solution
To address this compatibility issue and to enhance the library's usability within the TypeScript and modern JavaScript ecosystem, I kindly request the addition of ES module support. This could be achieved by:

  1. Providing an ES module build of the library alongside the CommonJS version.
  2. Ensuring named exports are correctly exported in the ES module format.

This enhancement would greatly benefit developers by allowing seamless integration with ES module-based projects and tools, improving developer experience and adoption.

Additional Context
I understand that adding ES module support may involve significant changes to the build and distribution process. However, considering the widespread adoption of ES modules in the JavaScript ecosystem, I believe this enhancement would align well with the needs of modern development workflows.

Thank you for considering this request. I am looking forward to any updates on this matter and am willing to assist or provide further information if needed.

Best regards,
Shino3 (@ shino3.net)

@alirobe
Copy link

alirobe commented Dec 5, 2024

+1, would significantly improve bundle size when only using a portion of the API. The prod bundle size impact is now ~900KB, and probably will be growing regularly.

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

No branches or pull requests

2 participants