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

Support Deno. How to get about implementing platform-deno? #1806

Open
pixeleet opened this issue Oct 29, 2023 · 13 comments
Open

Support Deno. How to get about implementing platform-deno? #1806

pixeleet opened this issue Oct 29, 2023 · 13 comments
Labels

Comments

@pixeleet
Copy link

I would be keen on getting platform-deno up and running as node compat is not 100% in Deno.
This would make Effect natively available in Deno.

@tim-smart @gcanti @fubhy @mikearnaldi
Any plans on supporting Deno so far?
What hurdles do we seen in implementing a platorm-deno?

@fubhy
Copy link
Member

fubhy commented Oct 29, 2023

The main hurdle I can see so far is that vitest doesn't play well with Deno afaik.

@pixeleet
Copy link
Author

I'm not sure I understand how and why vitest is relevant, Deno has it's own built-in test runner.
Do we need to run the Node test suite against the Deno platform?

@fubhy
Copy link
Member

fubhy commented Oct 29, 2023

As you mentioned, Deno is not 100% compat with Node. Hence, to prove that effect and @effect/platform works with Deno (and fix any possible instances where it doesn't) you'd have to run the whole test suite with Deno (because our existing test suite is based on vitest). Yes.

I've also recently opened a PR to add a test matrix that includes jsdom, edge and a Bun test run.

Note that we also had to introduce compat code to make the effect runtime work with Bun. I'd expect similar for Deno.

@tim-smart
Copy link
Member

Deno is on my list of things to do :)

The current plan:

  • Learn more about deno, package distribution strategies (will likely stick with npm to start with, to keep it simple)
  • See if deno can be added to the test suites for "effect", "@effect/platform" & the eventual "@effect/platform-deno"
  • Implement deno specific apis in a "@effect/platform-deno" package

For the first item, feedback is more than welcome from devs who have maintained cross-platform packages.

@fubhy
Copy link
Member

fubhy commented Oct 29, 2023

A quick google search revealed another package struggling with vitest on deno and attempting a polyfill approach: https://github.com/fabian-hiller/valibot/pull/179/files

Might be worth a shot. Although we might have to adjust some of our test utils in effect especially.

@pixeleet
Copy link
Author

pixeleet commented Oct 29, 2023

  • Learn more about deno, package distribution strategies (will likely stick with npm to start with, to keep it simple)

in denoland packages are ditributed simply by tagging them on git with a version and having a webhook set up to the deno registry. https://docs.deno.com/runtime/manual/advanced/publishing/#publishing-on-denoland

  • See if deno can be added to the test suites for "effect", "@effect/platform" & the eventual "@effect/platform-deno"

This is tricky, we can import @effect/platform from npm without a problem or use https://esm.sh for it, but I don't see how we would add / integrate it to the existing test suite. Deno has it's own test runner and behaves differently than say NodeJS built-in test runner or vitest.

  • Implement deno specific apis in a "@effect/platform-deno" package

Is @effect/platform entirely independent from nodejs? Can it be freely importad in Deno?

@fubhy What is this bun compat layer you mentioned?

@tim-smart
Copy link
Member

With some trial and error, the test suite for "effect" is working with deno in this PR: #1579

Will need to add the import map generation to our gen script.

@pixeleet
Copy link
Author

@tim-smart just did a quick glance on the PR, looks yummy, so essentially allowing importing TS extensions, it "just works"?

@pixeleet
Copy link
Author

pixeleet commented Nov 7, 2023

I think the testing story is covered now that deno 1.38 supports re-using packages installed by pnpm and vitest seems to work out of the box this way.

@tim-smart just merged #1579

@lishaduck
Copy link

lishaduck commented Jul 9, 2024

FYI: The linked denoland/deno#18546 has been closed as resolved as of denoland/deno#24334, and will likely land in the upcoming Deno 2 landed in Deno 1.45.
It still doesn't support Vitest fully though: denoland/deno#23882.

I can't wait to get to help with platform-deno!

@lishaduck
Copy link

I decided to take a stab at writing this (in userland), and I've got Path working and I've almost got Worker working!
Once I get Worker compiling, I'll push somewhere if anyone wants to try it (only for trivial stuff, without HttpClient it's pretty useless for now).

@lishaduck
Copy link

lishaduck commented Nov 13, 2024

🥁 Introducing @lishaduck/effect-platform-deno!

Supports the Path and Worker APIs natively,1 and uses Node compat for the rest (for now).

Footnotes

  1. Using jsr:@std/path and the browser-native Web Worker API.

@lishaduck
Copy link

I'm making good progress! I still need to iron out some wrinkles in DenoCommandExecutor, but DenoFileSystem is as complete as I'll be able to get for now. I plan on writing some more docs and upgrading to Deno 2.1 to improve the testing story before releasing 0.1.1 with FS support, probably sometime this weekend. 🤞

If this interests you, feel free to reach out and/or contribute! I'll probably quit posting over here so I don't disturb people who only care about 1st party solutions until that's a possibility. If you want to stay updated, you can subscribe over on lishaduck/effect-utils#1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Created
Development

No branches or pull requests

4 participants