effect icon indicating copy to clipboard operation
effect copied to clipboard

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

Open pixeleet opened this issue 2 years ago • 10 comments

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?

pixeleet avatar Oct 29 '23 19:10 pixeleet

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

fubhy avatar Oct 29 '23 19:10 fubhy

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?

pixeleet avatar Oct 29 '23 20:10 pixeleet

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.

fubhy avatar Oct 29 '23 20:10 fubhy

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.

tim-smart avatar Oct 29 '23 20:10 tim-smart

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.

fubhy avatar Oct 29 '23 20:10 fubhy

  • [ ] 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?

pixeleet avatar Oct 29 '23 20:10 pixeleet

With some trial and error, the test suite for "effect" is working with deno in this PR: https://github.com/Effect-TS/effect/pull/1579

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

tim-smart avatar Oct 30 '23 00:10 tim-smart

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

pixeleet avatar Oct 31 '23 15:10 pixeleet

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 https://github.com/Effect-TS/effect/pull/1579

pixeleet avatar Nov 07 '23 23:11 pixeleet

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 avatar Jul 09 '24 01:07 lishaduck