surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
271 stars 46 forks source link

Migrate to JSR + minor updates #272

Closed sachaw closed 1 week ago

sachaw commented 1 month ago

Thank you for submitting this pull request! We appreciate you spending the time to work on these changes.

What is the motivation?

The Deno team has launched JSR You can read about it here: https://deno.com/blog/jsr-is-not-another-package-manager It would be great to have this package published there

What does this change do?

This PR changes the following:

  1. Updates deno.json to use the new fields: name, version, description, replacing project.json
  2. Uses deno.json's import map to specify package versions, using packages published to JSR where possible
  3. Replace semver with Deno's @std/semver
  4. Added as many return type annotations as I could, JSR want's all public return types to be explicitly typed. Right now I have left those returning Zed functions as they are very verbose.
  5. Added vscode defaults for default formatter and format on save
  6. Added export map to deno.json to export mod.ts
  7. Updated a few CI action versions & added a JSR publish step
  8. Add Pull Request CI workflow to check formatting and run tests

What's required if this PR is accepted is for a JSR JSR account and namespace to be created, I have specified @surrealdb and to register the package name surrealdb. Then under the publish settings, specify this github repo to enable automatic provenance and publishing

Thanks.

Have you read the Contributing Guidelines?

kearfy commented 1 month ago

Hey @sachaw, wow! This is an amazing PR, thank you so much!

One note I have is that I have been using NPM packages with the reason that it's more likely that people already have X npm package installed compared to a Deno or JSR package, which would save a bit on bundle size. For that reason, I would personally opt to stick with the NPM semver package that was previously used. I'm happy to hear your thoughts however!

sachaw commented 1 month ago

Thanks for that, Whilst I do agree with not blowing out the bundle size. The semver package currently published to npm is a very old, and outdated cjs package, with no native typescript types bundled. While the @std/semver package may add a few kb to a project, the increase in quality and auditability is worth it IMO.

kearfy commented 4 weeks ago

Alright, that's cool! I haven't forgotten your PR by the way, I simply need to find some time to have a proper look and merge it in. This is great!

kearfy commented 1 week ago

Hey @sachaw, I really appreciate the effort you put into this project! We were unfortunately planning to change from Deno to Bun for a little while already, which also covers publishing to JSR.

While I have to close your PR, I'm happy to share that publishing to JSR is added in #291, and all methods are now statically typed as per the JSR guidelines.

Have a nice weekend!