https://www.npmjs.com/package/@atproto/lex
https://bsky.app/profile/matthieu.bsky.team/post/3m6fv5htpk22w
I tried to use this new package in our climateai-sdk , a few days back. Here are my thoughts and findings about it:
Before adding the new package, there were a dependencies and dev dependencies from @atproto being used, such as:
@atproto/api : For querying and other operations in the PDS and repositories.@atproto/lex-cli : For generating types and classes for the lexicons@atproto/oauth-client-node or any other auth package: For handling the auth operations.This new package was a straight up replacement for all the three packages in one go.
The previous packages internally used other @atproto packages, which themselves used some other @atproto package, hence making the dependency tree very complex… This was hard for tree shaking and the bundle sizes were naturally larger.
The new package on the other hand was tree-shaked and had very small bundle size.
The previous packages, if installed uncarefully, the dependencies might end up being different versions, with varying definitions of types such as BlobRef that are hard to track down. They look similar when you look at them, and even the typescript compiler won’t show any errors but if somewhere in the code you used blob instanceof BlobRef, it might unexpectedly return false at runtime, because two or even three different versions of the BlobRef class might exist and you don’t know which one is being used where.
The new package does not even have a complete “BlobRef” class at all. The BlobRef class has methods to convert it to and from a json to object, which help with serializations… Its gone and replaced with just a type.
There is no way to upload a blob on PDS yet, when using the new package which is quite essential feature.
It’s obviously very new:
[!IMPORTANT]
This package is currently in preview. The API and features are subject to change before the stable release.
