Giter Site home page Giter Site logo

linecode / jsx-lite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from builderio/mitosis

0.0 2.0 0.0 1.27 MB

Write components once, run everywhere. Compiles to Vue, React, Solid, Liquid, Svelte, and more.

License: MIT License

JavaScript 2.30% TypeScript 93.57% Shell 0.05% HTML 3.81% CSS 0.27%

jsx-lite's Introduction

Write components once, run everywhere. Compiles to Vue, React, Solid, Liquid, and more.

Why

Component libraries

Managing support for libraries that provide logic or functionality meant to be used across frameworks (e.g. Material, Semantic, SDKs, etc.) is a pain. There are no viable current solutions for writing logic once and instantly having a version that works natively across frameworks.

An organization might want to build a new component library to be used across the business, but they also have teams working with different frameworks (e.g. React, Vue, Angular). Writing the library in JSX lite allows the component team to write the logic once and let each team consume the components in different formats.

No-code tools

We want to bridge the gap between code and no-code. No-code tools require a higher level of abstraction and allow a rich and intuitive editing experience. But that abstraction usually means less control for those who know how to code, and the inability to work no-code workflows into the development cycle.

With JSX lite, you can drag/drop to build UIs and edit the code side by side, generating usable and editable code as you need to. Support for no-code tools like Builder.io is in active development, and other tools like Figma will be supported in the future.

Modern unified workflows for all platforms

JSX lite allows you to incrementally adopt modern and familiar workflows for many different platforms. For example, Shopify is an enormously powerful ecommerce platform, but only supports rendering server-side with their Liquid templating language. This means people either need to build Shopify stores with Liquid + jQuery, or opt to not render server-side at all.

JSX lite allows you to modernize your workflow by generating Liquid code that hydrates to React in the browser, making your store high speed and SEO friendly with SSR while still having fast and clean renders on the client. This flow could even allow your site to become a SPA after the first page load (no more server-side navigation after the first load).

JS framework fatigue

If you have ever had to migrate a huge codebase from one framework to another, it's an absolute nightmare. Writing at a higher level of abstraction allows you to move from one to another with ease. It also allows for incremental adoption of a new framework without having to write logic twice.

Plus, if a new framework comes along that you are just itching to try and think will solve your site's performance problems, all you need is to run a command to get a version of your app with that new framework. Bye bye rewrites!

How does it work

JSX Lite uses a static subset of JSX, inspired by Solid. This means we can parse it to a simple JSON structure that it is easy easy to build stringifers off of for various frameworks and implementations

export function MyComponent() {
  const state = useState({
    name: 'Steve',
  });

  return (
    <div>
      <input
        value={state.name}
        onChange={(e) => (state.name = e.target.value)}
      />
    </div>
  );
}

becomes:

{
  "@type": "@jsx-lite/component",
  "state": {
    "name": "Steve"
  },
  "nodes": [
    {
      "@type": "@jsx-lite/node",
      "name": "div",
      "children": [
        {
          "@type": "@jsx-lite/node",
          "bindings": {
            "value": "state.name",
            "onChange": "state.name = event.target.value"
          }
        }
      ]
    }
  ]
}

Which can be reserialized into many languges and framworks. For instance, to support angular, we just make a serializer that loops over the json and produces:

@Component({
  template: `
    <div>
      <input [value]="name" (change)="name = $event.target.value" />
    </div>
  `,
})
class MyComponent {
  name = 'Steve';
}

Adding framework support is surprisingly easy with our plugins (docs coming soon!)

No-code tooling

JSX Lite's static JSON format also enables no-code tooling for visual code editing, for instance with Builder.io or Figma (coming soon)

Who uses it

Status

Framework Status
React Alpha
Vue Alpha
Liquid Alpha
Builder Alpha
Solid Alpha
Svelte Planned
Figma Planned
React Native Planned
Angular Planned

Coming soon

  • JSX Lite Fiddle
  • Stable (v1) release
  • Plugin API docs for custom syntaxes and extensions
  • Integration with design tools like Figma (Figma <-> JSX Lite)

Made with ❤️ by Builder.io

jsx-lite's People

Contributors

ca136 avatar mrkoreye avatar steve8708 avatar sudotechie avatar tmikeschu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.