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 for pluggable renderers #20

Closed
rauchg opened this issue Oct 16, 2016 · 11 comments
Closed

Support for pluggable renderers #20

rauchg opened this issue Oct 16, 2016 · 11 comments

Comments

@rauchg
Copy link
Member

rauchg commented Oct 16, 2016

Like inferno or preact.

From the end user perspective, it would work as follows.
Configure package.json:

{
  "dependencies:" {
    "next": "x.y.z",
    "next-preact": "x.y.z",
    "preact": "x.y.z"
  }
}

Then we transform JSX to the pragma that, in this example, next-preact would need.
The rendering pipeline would similarly be pluggable.

@rauchg rauchg mentioned this issue Oct 16, 2016
@developit
Copy link
Contributor

Willing to help on this, any pointers for where to start?

This was referenced Oct 26, 2016
@trueadm
Copy link

trueadm commented Oct 26, 2016

I'm also totally down to getting Inferno fully working with Next as this project is beyond awesome in my opinion. Great work guys :)

@rektide
Copy link

rektide commented Nov 27, 2016

I started trying to see what this would take to implement. I thought this was going to do it, but not seeing any changes.
https://github.com/rektide/next.js/tree/preact-compat

Update: now getting some test failure:

Error: ./dist/client/head-manager.js
Module not found: Error: Cannot resolve module 'preact-compat/lib/HTMLDOMPropertyConfig' in /home/rektide/src/next.js/dist/client
resolve module preact-compat/lib/HTMLDOMPropertyConfig in /home/rektide/src/next.js/dist/client
  looking for modules in /home/rektide/src/next.js/node_modules
    resolve 'file' or 'directory' lib/HTMLDOMPropertyConfig in /home/rektide/src/next.js/node_modules/preact-compat
      resolve file
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig doesn't exist
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.webpack.js doesn't exist
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.web.js doesn't exist
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.js doesn't exist
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.json doesn't exist
      resolve directory
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig doesn't exist (directory default file)
        /home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig/package.json doesn't exist (directory description file)
[/home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig]
[/home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.webpack.js]
[/home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.web.js]
[/home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.js]
[/home/rektide/src/next.js/node_modules/preact-compat/lib/HTMLDOMPropertyConfig.json]

HTMLDOMPropertyConfig does not appear in the Preact or preact-compat codebase. It's use in Next.js is exclusively in head-manager. I tried commenting out the import and it's use as so but got 3 other test errors that were a bit harder to decipher: const attr = /*HTMLDOMPropertyConfig.DOMAttributeNames[p] ||*/ p.toLowerCase(). I still haven't really started figuring out what it's asking for or what React is providing here.

@rauchg
Copy link
Member Author

rauchg commented Nov 27, 2016

Very impressive @rektide ! Looking forward to seeing this evolve. Ideally we get it down to 2 imports (next-preact and preact peer dep) and 1 tweak on the config :)

@matthewmueller
Copy link
Contributor

matthewmueller commented Dec 1, 2016

Piggybacking off @rektide's work, I was able to get it working by...

git clone https://github.com/zeit/next.js next
cd next
npm install
npm install -i preact-compat/react preact-compat/react-dom preact preact-compat
# comment out HTMLDOMPropertyConfig
npm build # this will fail on the tests, but will still give you a dist/client
# copy that dist/client to whatever app you've got next running on

Some additional work needs to be done to figure out how to make HMR play nice with non-react things. react-hot-loader does some crazy stuff. @developit has minimalist way to make HMR work more universally: preactjs/preact#168 (comment)

I think the big things needed from next are:

  1. remove the dependency on HTMLDOMPropertyConfig, it can just be a map copied into next or a separate module.
  2. replace react-hot-loader with something that just adheres to the HMR API.

@lukeed
Copy link
Contributor

lukeed commented Dec 1, 2016

@matthewmueller Tests pass for me!

@rauchg
Copy link
Member Author

rauchg commented Dec 1, 2016

That's really amazing (and simple) @matthewmueller

@lukeed
Copy link
Contributor

lukeed commented Dec 2, 2016

Both inferno & preact lack a HTMLDOMPropertyConfig component, but I'm not sure that they should need to offer one...

@rauchg
Copy link
Member Author

rauchg commented Dec 3, 2016

Paging @nkzawa and @arunoda. I think we should think about even documenting in the Wiki what the API surface that we depend on from React is. This will allow people to keep experimenting with engine improvement and minimization :)

@rauchg
Copy link
Member Author

rauchg commented Dec 28, 2016

This is already possible with simple webpack overrides.

@rauchg rauchg closed this as completed Dec 28, 2016
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants