Any attempts at UI building with InfernoJS?


#1

Just wondering if anyone has tried building a UI with Inferno instead of React?


#2
  1. Why? Inferno might yield a smaller bundle (Preact is a great deal smaller though), but at a scale where static types would shine, it probably doesn’t matter much.
  2. It seems like Inferno haven’t implemented hooks yet. ReasonReact bindings for React classes are unmaintaned and pretty awkward to use. Hooks have way better chemistry with Reason.

#3

I’m interested primarily because of rendering speed. Inferno is much faster. I’m very interested in PWAs and speed is of great importance when trying to achieve an app-like experience.


#4

Well, if you’re sure your bottleneck is in the VDom diffing and not in, say, unnecessary rerendering (I do hope you’ve measured), you can write the bindings yourself. But keep in mind that the ReasonReact record API had some runtime overhead, whereas the hooks API has none. So you’re gonna lose some of the speed.


#5

A while ago I tried aliasing React to Inferno (inferno-compat) using rollup-plugin-alias, and it worked out of the box with the old ReasonReact API. Everything in my app other than event handling in Shadow DOM worked without any difference.

Found this rollup config change in an old stash, in case it helps:

+import alias from "rollup-plugin-alias";
+import path from "path";
 
     plugins: [
+      alias({
+        react: path.resolve(
+          __dirname,
+          "node_modules",
+          "inferno-compat",
+          "dist",
+          "index.esm.js"
+        ),
+        "react-dom": path.resolve(
+          __dirname,
+          "node_modules",
+          "inferno-compat",
+          "dist",
+          "index.esm.js"
+        ),
+        "./ReasonReactOptimizedCreateClass.js": path.resolve(
+          __dirname,
+          "node_modules",
+          "inferno-create-class",
+          "dist",
+          "index.esm.js"
+        )
+      }),

#6

It’s a non-existent app right now. I’ve worked with large React apps in the past and, while they fly on desktop, they stutter on even powerful mobile devices, to say nothing of mid-range phones.


#7

Awesome! I was hoping someone would say exactly what you just said. I just wanted hope that it wasn’t a blind alley or a huge lift for minor benefit.