Code Monkey home page Code Monkey logo

react-lego's Introduction

This version is currently being update for 2018. The previous react-lego, with older version of tech and upgrade paths, can be found react-lego-2017

React Lego 2018 CircleCI

The building blocks of a react app

This repo demonstrates how to plug in other technologies, one block at a time, into React.

Hear me out!

The concept is to use GitHub's branch-comparison screens to quickly demo the code changes that are needed for only the technology you are interested in.

A client-side React app which is fully tested and production ready on the master branch.
From Master, Server-side Rendering (SSR) has been added with Koa v2 (for Express see react-lego-2016).
Every other branch then adds one more technology, with the smallest possible changes.

All branches, have been setup with continuous deployment.

>> More about the react-lego concept

What else the Base React app have?

It is production ready and fully tested :

All other branches include the above and build on this base.

Technology to Add:

All branches use babel v7, React v16.2, react-router v4, Webpack v4 unless otherwise stated

The Code changes column is where you go if you want to see how the code changed from the previous branch. This is a great place to see how to do it yourself.

Category Code changes App size (node_modules) Comparator kb
Client-side Rendering React 23kb (+152kb)
Server-side Rendering add Koa v2 22kb (+153kb)
CSS add CSS Imports 22kb (+153kb ) CSS Modules >> More about adding CSS
State Management add Redux 22kb (+188kb) >> More about adding Redux

Previous branches still to be updated

These branches are from React Lego 2017 and are on my 'todo' list to update!

Category New Tech Code changes Client-side App (kb) Comparator kb
Client-side Rendering Preact > Preact code vs React tbc >> More about adding Preact
State Management Async routes add async routes tbc >> More about adding Promise middleware
Assets Importing SVGs
Assets Responsive Images with PNGs
Data API GraphQL add GraphQL tbc Apollo tbc

What else ?

I have a few articles that may be interesting to read covering all the branches in this repo: >> wiki


** Something missing? Please see react-lego-2017 or react-lego-2016 or submit a feature request!**


react-lego's People

Contributors

lemaik avatar peter-mouland 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  avatar  avatar  avatar  avatar  avatar

Watchers

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

react-lego's Issues

[master/webpack2-*] 'npm start` use development build

issue come from master branch but very visible in webpack2-hrm branch

Steps to reproduce

  1. set your NODE_ENV to development
  2. run npm run start:dev
  3. kill it and run npm run build:server and npm run start .
  4. Notice env still set to development. build does sets NODE_ENV to production but it does so after build:server in prestart
  5. open localhost:3000 with network - watch /__webpack_hrm request.

Expected
Manage node_env more consistent.

Suggestion

  "prestart": "rm -rf compiled && npm run build:server && npm run build",
  "prestart:dev": "NODE_ENV=development npm run build:dev",
    "build": "NODE_ENV=production webpack --config src/config/webpack.config.prod.js --optimize-minimize",
    "build:dev": "NODE_ENV=development webpack --config src/config/webpack.config.dev.js",
    "build:server": "NODE_ENV=production webpack --config src/config/webpack.config.server.js",

Suggestion: Performance comparisons

Since you guys rolled out all these different options, it would be great to see load time comparisons in order to see how they each perform independently (bundle.js, css, etc)

Thank you and great work

Solved: Getting syntax error on start:dev

I am new to webpack, and to github, so if this is not the right area to ask this question then please point me in the right direction.

I must have some sort of config issue on my side with babel. I cloned the react-hot-loader branch, and when I run the start:dev script, npm gets to the build:dev script I get a Syntax error:

/react-lego/src/config/webpack.config.dev.js:4
const { SRC } = require('./paths');
      ^ 

Any idea what I'm doing wrong?

Fetching server-side data with async routes

Hi Peter, thx for this awesome repo! I'm currently working on an implementation of server-side rendering and your guide at: https://github.com/peter-mouland/react-lego/wiki/Redux-Promise-Middleware helped a lot.

I've stumbled upon an issues using sync routes however and I'm curious if you have any insights on the following scenario:

  1. Render app component and fetch data on the server side using the needs construction
  2. App component generates routes based on fetched data
  3. Generated routes point to new component that also have data needs (which I would like to render on the server)

With your current solution only the data needs for the app component are resolved on the server because the data needs of sub components become available after the resolve of the initial data. At this point the server already returns because it doesn't know about new data needs.

What are your ideas about this?

tidy up & stream-line react-lego

todo:

  • archive an origin react lego into react-lego-2016 repo.
  • refactor base client-side app to use latest versions.
  • remove old branches that demo upgrade paths.
  • mention react-lego-2016 in readme to help point people to old upgrade examples.
  • remove express branches (koa v2 ftw) as there are plenty of express examples.
  • update wiki
  • ensure lego 2017 focuses on dev experience and and perf

Firebase Branch

I'm not sure what the popularity of this is like, but I was thinking that maybe we can include a firebase branch as well, either branching off from universal(for server side rendering) or the master branch (for client side only).

DEBUG=lego:* Error

When i try to start, I am getting error here DEBUG=lego:* on windows, anyway i removed that tested all features.

One more question, where is the branch which has all integrated? your master branch is not having the redux integrated.

Thanks.

"webpack-dev-server": "^1.14.1", in Webpack v2 HRM

webpack-dev-server 1.14 requires webpack 1.

webpack-dev-server now has 2.1.0-beta.8 that support webpack 2.
Note: there are breaking changes in beta3

Also "purifycss-webpack-plugin": "^2.0.3", required webpack 1

koa react app 404

building an all singing Koa-app, but implimenting react-router-addons-routes (to help with server-side data fetching with react-router-v4) causes the api return to 404.

Think the generators of koa are to blame, not the above plugin...

Enable es6 syntax in server code.

Hey,
So I noticed this is not really an issue of sorts, but I'm not really sure if its a quick fix or not. I want to be able to use es6 code in my server-side. That means, all that fancy spread operators, imports, etc...
I noticed if I do that, when I try to do an npm start, it will fail because it won't recognize those es6 syntax. We can set it up maybe so it transpiles down first and then webpack will pick it up.

Compilation fails for svg branch

Hey, I think this is an isomorphic webpack issue. I noticed that npm start( which does the compilation for the server build) fails for the svg branch. Not exactly sure the issue and was wondering if you can look into that.

Error trying to do run start:dev on svg-isomorphic-loader branch

 lego: Environment: { DEBUG: 'lego:*', NODE_ENV: 'development', PORT: '3000' } +0ms
  lego: server-entry ReferenceError: React is not defined
    at Object.<anonymous> (/Users/ngoctranfire/Desktop/react-lego/src/app/containers/Game/assets/chevron.svg:1:1)
    at Module._compile (module.js:541:32)
    at loader (/Users/ngoctranfire/Desktop/react-lego/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/ngoctranfire/Desktop/react-lego/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Function.Module._load (/Users/ngoctranfire/Desktop/react-lego/node_modules/isomorphic-loader/lib/extend-require.js:79:29)
    at Module.require (module.js:466:17)
    at require (internal/module.js:20:19) +801ms

This error appears when I try to run npm run start:dev in the svg-isomorphic-loader branch. I think this is an outdated branch, and the svg branch is probably the one we should be using. If that is correct, we can just close this issue.

create react-lego for 2018

  • Fork / Retire / start a new React Lego
  • React 16
  • Webpack 4
  • Babel 7
  • Use CSS Custom Props over sass variables
  • use my own custom BEM helper
  • Switch to Jest for code-coverage ease
  • Manually include required poly-fills to reduce bundle-size (and write up!)
  • Compare redux with redux-zero
  • Show how to create and re-use a shared vendor bundle
  • compare vanilla GraphQL with Apollo
  • spike perf testing
  • create separate bundles w/ ctm test for es modules
    • ...perhaps a separate project, show how to combine many lego-kits

Hot-reload branch does not work as expected

Sorry to be filing so many bugs and such, but I really like your project and its actually helped me to learn redux by the pieces and get to understand the numerous moving parts that are so confusing to me.
On your react-hot-loader branch, just by itself, I noticed that it just doesn't work correctly. When I make a change, the changes are not updated automatically. Also, I was getting this error at the beginning: not sure if it's related.

HMR] Update check failed: Error: Manifest request to /6a46934f57636f62dc58.hot-update.json timed out. at XMLHttpRequest.request.onreadystatechange (http://localhost:3000/app.js:34:23)

GraphQL implementation

I'm currently using Meteor for both client and server builds. However with the activity and movement around GraphQL, I believe it could be a very viable option to opt for a client-only build without involving Meteor at all on the client. I also think this would speed up development by using webpack and getting out of Meteor's slow build process.

Any possibility of adding a sample GraphQL item to your list? Can use the just released GitHub GraphQL API for a sample: https://developer.github.com/early-access/graphql/

I also wonder how this would affect Redux (if at all).

btw I LOVE LOVE LOVE this repo! So many great examples.

set-router-context.js in redux branch does not properly handle routing

I'm not super sure, but I took a look at the set-router-context.js and actually tried setting this up with my own project, but I noticed that it looks like the routes we are passing into the match() function does not have a history object, and a route that has correctly been synced with the redux store.

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.