Code Monkey home page Code Monkey logo

strike's Introduction

Strike

Did you know that "hello".strike() is a valid JavaScript expression? This project will blow your mind with this and other useless usefull facts.

Why

We do what we must because we can.

-- GLaDOS

This is a proof of concept that it's actually possible to generate React Server Components with backends other than Node.js. In this case, Go.

By using Go and simplified implementation of RSC, hopefully we give you a nice playground that will help you understand the principles behind RSC better.

The name strike doesn't have any special meaning, but it had two things going for it:

  • name wasn't taken
  • both html tag <strike> and JavaScript method String.prototype.strike are deprecated

Project goals

  • educate people about React Server Components (outside of Next.js/Node/Vercel ecosystem)
  • not to use react-server-dom-webpack at all, opting for a simpler (to understand) implementation instead
  • get 10x performance improvement over Next.js for some synthetic use cases

Pre-requisites

Install air for development.

Run

air
# or
go run app.go

Test

air --build.bin "go test ./..." --build.exclude_regex "" --build.cmd "true"
# or
go test ./...

Caution

I don't understand how HTML escaping works in Go, so I assure you there's prenty of XSS vulnerabilities in this code.

More

This was built in public, you can watch it in the YT Playlist.

As seen on TV: https://youtu.be/7Co0qXGcE5I?si=FMfj45GB8A-lWy1P

Profiling

Click to expand
brew install graphviz
# or
apt-get install graphviz gv
go get -u github.com/google/pprof
air --build.bin "go test -cpuprofile cpu.prof -memprofile mem.prof -bench=^Benchmark github.com/JLarky/strike/pkg/strike" --build.exclude_regex "" --build.cmd "true"

pprof -http=:3000 cpu.prof
pprof -http=:3000 -no_browser mem.prof

strike's People

Contributors

jlarky avatar patrickjs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

strike's Issues

Roadmap

To plan these things:

  • port notes app to strike
  • write a blog explaining what is happening

TODO soon:

  • server actions
  • streaming (server Suspense component)
  • client components SSR
  • support using npm dependencies

idea: use html templating to render

It would be cool to find a way to straight up use html/template for server components. The trick is to find a way to parse HTML and turn it into JSON; as well as mark islands so that we can use client references to render those on the client. This must be pretty similar to how islands in SolidStart work.

tmpl := template.New("index.html")
b := new(bytes.Buffer)
err := tmpl.Execute(b, map[string]interface{}{
	"MyIsland": Island("MyIsland"),
})

to turn that html on the client to JSX that could be used to hydrate React is going to be fun :) you can probably use dangerouslySetInnerHTML :) or you would need to have props that are in a special format, like

<button disabled strike:disabled="boolean:true" />

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.