pocketbase / js-sdk

PocketBase JavaScript SDK
https://www.npmjs.com/package/pocketbase
MIT License
2.15k stars 128 forks source link

Make the library source Deno first. #9

Closed tracker1 closed 2 years ago

tracker1 commented 2 years ago

Deno requires a .ts as part of the import statement, by doing that change and adding a /mod.ts in the root of the project containing export * from "./src/index.ts it would be easy enough for deno users to reference from github raw content directly (in the near term).

From there, easy enough to make a clone of the src/ directory, and remove the .ts in the import lines... would only need to change the existing build configuration to make that copy, with the changes, then use tmp-src for tests and builds for browser and node usage.

Note: this would make testing slightly more complex... but could probably replace the test harness with Deno's built in testing framework. Which would simplify dependencies and output.

After that, could do a publish to https://deno.land/x to make the package more easy to discover. I know it may seem backward to suggest targeting the least used platform first, but it would be the easiest path towards the other two.


If there's interrest, I'd be happy to help on such a transition.

ganigeorgiev commented 2 years ago

Hi,

Because of bundling issues with commonjs modules (axios, qs) and trying to make them work on every environment, I've rewritten the core and have removed the 3rd party dependencies in v0.2.0.

Now the library is using only fetch() which should be supported by Deno (haven't got the time to test, but the documentation says that it is since Deno v1.0.0).

As a bonus the size was also reduced, from ~75kb to ~23kb (or ~5kb gzipped!).

Please give it a try and share your feedback.

ganigeorgiev commented 2 years ago

I'll close the issue for now, because I'm not planning to make the library Deno first, because it will complicate the build process and will introduce some maintenance burden since I'm not very uptodate with Deno.

The recent fetch rewrite should simplify loading the SDK, but if anyone is still having difficulties, feel free to let me know and I'll research it more thoroughly.

rojvv commented 1 year ago

The build process won’t be complicated: Just use deno2node or https://github.com/denoland/dnt.

rojvv commented 1 year ago

Here’s a Deno-first library we’ve been working on for years, that supports CJS Node.js and browsers as well: https://github.com/grammyjs/grammy