Effect-TS / effect

An ecosystem of tools for building production-grade applications in TypeScript.
https://effect.website
MIT License
7.13k stars 226 forks source link

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

Open pixeleet opened 10 months ago

pixeleet commented 10 months ago

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 commented 10 months ago

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

pixeleet commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

Deno is on my list of things to do :)

The current plan:

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

fubhy commented 10 months ago

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 commented 10 months ago
  • [ ] 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 commented 10 months ago

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.

pixeleet commented 10 months ago

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

pixeleet commented 10 months ago

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

lishaduck commented 2 months ago

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!