remix icon indicating copy to clipboard operation
remix copied to clipboard

[Feature] Preact Support

Open developit opened this issue 2 years ago • 18 comments

Preact Support

  • [x] Skip <Scripts> diffing on the client (change in Remix)
    • ~#390~
    • ~#403~
    • #422
  • [x] Backport <!DOCTYPE> hydration skipping to Preact 10 (change in Preact)
    • preactjs/preact#3327
  • [ ] Land patch for document.documentElement replacement (change in preact/compat)
    • preactjs/preact#3328

developit avatar Nov 22 '21 16:11 developit

preactjs/preact#3327 has been published in 10.6.0, we can also merge in the document.documentElement patch later unless we want to fix this another way?

JoviDeCroock avatar Nov 23 '21 16:11 JoviDeCroock

I'm very excited about Preact support for Remix. What can I do to help?

pspeter3 avatar Jan 04 '22 16:01 pspeter3

Hey @pspeter3 it should work as of now, the only thing we need to do different is the hydrate call. Rather than hydrate(x, document) we'll need to do

const documentElement = document.documentElement;
const apply = n => document.replaceChild(n, documentElement);
hydrate(x,  {
	childNodes: [documentElement],
	firstChild: documentElement,
	insertBefore: apply,
	appendChild: apply
}

This because of our algo getting a bit confused 😅 we're hoping to land a fix but looking into the best way currently

https://twitter.com/_developit/status/1471294946560851969

JoviDeCroock avatar Jan 04 '22 16:01 JoviDeCroock

Thanks! Is https://github.com/preactjs/preact/pull/3328 the right issue to follow from the Preact side?

pspeter3 avatar Jan 04 '22 16:01 pspeter3

Well that was an initial solution but we're trying to find a smaller (and maybe in core) one

JoviDeCroock avatar Jan 04 '22 17:01 JoviDeCroock

Is there an example repo with this work around used? Preact is awesome :D

Hey @pspeter3 it should work as of now, the only thing we need to do different is the hydrate call. Rather than hydrate(x, document) we'll need to do

const documentElement = document.documentElement;
const apply = n => document.replaceChild(n, documentElement);
hydrate(x,  {
	childNodes: [documentElement],
	firstChild: documentElement,
	insertBefore: apply,
	appendChild: apply
}

This because of our algo getting a bit confused 😅 we're hoping to land a fix but looking into the best way currently

https://twitter.com/_developit/status/1471294946560851969

arjunyel avatar Jan 19 '22 22:01 arjunyel

After some hours of implementing Preact in Remix, I finally found how annoying not having access to the Bundler API can be. And even after patching Remix compiler.js file, it still didn't work because of compatibility between Preact 8 and Preact X, and I didn't manage to make Preact X work with ESBuild. It would be cool if Jovi guided us in the correct direction on implementing it in Remix, as Preact is a key factor in performance optimization.

phiberber avatar Jan 24 '22 01:01 phiberber

I would love to help out but we're not going to work on supporting 8 😅 else we'd be working on three major versions at once, I'll try to contribute a working example in the coming week

JoviDeCroock avatar Jan 24 '22 08:01 JoviDeCroock

@phiberber https://github.com/remix-run/remix/pull/1636 adds an example

JoviDeCroock avatar Jan 24 '22 15:01 JoviDeCroock

Is there any update on this? The example PR was closed with the status "we are waiting to get this natively supported".

isaac-mcfadyen avatar Jul 05 '22 17:07 isaac-mcfadyen

Haven't heard back about this 😅

JoviDeCroock avatar Jul 05 '22 17:07 JoviDeCroock

Jovi, should've waited for the official implementation before deleting the example branch, anyone can follow the commit steps though.

It has been a couple months already, I'm not even sure if this is going to be released this year, and based on this issue's activity, seems like thete is little to none demand (compared to other issues).

phiberber avatar Jul 05 '22 18:07 phiberber

I do know the Remix team really wants to make Remix front-end agnostic. Preact has always been at the top of their list. With summer vacations and the major update to React Router, I believe this work was put on hold. It should pick back up soon after the new "Remix" router lands (with the data API) and deferred support.

kiliman avatar Jul 05 '22 18:07 kiliman

There's also the remix routers repository, where work is being done to port react-router-dom based on the underlying @remix-run/router. I think it's currently on for Vue & Svelte is in the works. I personally didn't commit to doing any work because of the statement made by Ryan about native support 😅.

There was also a tweet from Ryan himself playing around with Preact & HTM. He's importing what is a pre-release of the remix-router package, so I would presume there's some work that was already done.

Klukies avatar Jul 08 '22 07:07 Klukies

@LukasCornille I've done an initial pass of a Preact layer here: https://github.com/brophdawg11/remix-routers/pull/19

jacob-ebey avatar Sep 08 '22 21:09 jacob-ebey

Example with Deno https://twitter.com/ebey_jacob/status/1567055958727340032

arjunyel avatar Oct 04 '22 18:10 arjunyel

What would it take to get official support at this point?

pspeter3 avatar Oct 28 '22 15:10 pspeter3