You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 31, 2024. It is now read-only.
- removes Styled Components; adds [Emotion](https://emotion.sh/) CSS-in-JS - adds [MobX](https://mobx.js.org/) - adds local state to `src/data/state.ts` - adds server dehydration/client hydration of MobX state - adds `src/lib/mobx.ts`, with helper functions for dehydration and feeding state context to React via `<StateProvider>` - adds `<StateConsumer>`, which takes a function and passes it local state; automatically re-renders React children when state is mutated - replaces Apollo local state counter example queries, state and mutations, and replaces with an `increment()` function on state - moves Apollo to `src/lib`; removes redundant `src/apollo` - removes `src/queries` - removes `src/mutations` - replaces Styled Components global with Emotion's `<Global>` type - adds new multi-build Dockerfile; bumps Node to 11.8 - removes theming - adds `scripts()` to `src/lib/stats.ts`, for finding related `.js` files to bootstrap on initial HTML render (wip toward adding cached, per-request vendor files) - dumps a full stack trace to the console in the event of a server error on any route, instead of just the message, for easier debugging - refactors `src/views/ssr.tsx` component to produce a map of `<script>` tags instead of taking a `js` var - updates readme
Copy file name to clipboardExpand all lines: README.md
+25-29Lines changed: 25 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,50 +13,52 @@ https://reactql.org
13
13
14
14
-[React v16](https://facebook.github.io/react/) for UI.
15
15
-[Apollo Client 2.0 (React)](http://dev.apollodata.com/react/) for connecting to GraphQL.
16
-
- Fully typed [Styled Components v4](https://www.styled-components.com/), with inline `<style>` tag generation that contains only the CSS that needs to be rendered, and full theming.
16
+
-[MobX](https://mobx.js.org/) for declarative, type-safe flux/store state management (automatically re-hydrated from the server.)
17
+
-[Emotion](https://emotion.sh/) CSS-in-JS, with inline `<style>` tag generation that contains only the CSS that needs to be rendered.
17
18
-[Sass](https://sass-lang.com/), [Less](http://lesscss.org/) and [PostCSS](https://postcss.org/) when importing `.css/.scss/.less` files.
18
19
-[React Router 4](https://github.com/ReactTraining/react-router/tree/v4) for declarative browser + server routes.
19
-
-[Apollo Link State](https://www.apollographql.com/docs/link/links/state.html) for local flux/store state management (automatically re-hydrated from the server.)
20
+
20
21
- Declarative/dynamic `<head>` section, using [react-helmet](https://github.com/nfl/react-helmet).
21
22
22
23
### Server-side rendering
23
24
24
25
- Built-in [Koa 2](http://koajs.com/) web server, with async/await routing.
25
26
- Full route-aware server-side rendering (SSR) of initial HTML.
26
27
- Universal building - both browser + Node.js web server compile down to static files, for fast server re-spawning.
27
-
- Per-request GraphQL local state. Store state is dehydrated via SSR, and rehydrated automatically on the client.
28
+
- Per-request GraphQL store. Store state is dehydrated via SSR, and rehydrated automatically on the client.
29
+
- MobX for app-wide flux/store state, with a built-in `<StateConsumer>` for automatically re-rendering any React component that 'listens' to state and full client-side rehydration. Fully typed state!
28
30
- Full page React via built-in SSR component - every byte of your HTML is React.
29
31
- SSR in both development and production, even with hot-code reload.
30
32
31
33
### Real-time
32
34
33
35
- Hot code reloading; zero refresh, real-time updates in development.
34
36
- Development web server that automatically sends patches on code changes, and restarts the built-in Web server for SSR renders that reflect what you'd see in production.
35
-
-New in v3.5: WebSocket `subscription` query support for real-time data (just set `WS_SUBSCRIPTIONS=1` in [.env](.env))
37
+
- WebSocket `subscription` query support for real-time data (just set `WS_SUBSCRIPTIONS=1` in [.env](.env))
36
38
37
39
### Code optimisation
38
40
39
41
-[Webpack v4](https://webpack.js.org/), with [tree shaking](https://webpack.js.org/guides/tree-shaking/) -- dead code paths are automatically eliminated.
40
42
- Asynchronous code loading when `import()`'ing inside a function.
41
-
- Aggressive code minification.
43
+
- Automatic per-vendor chunk splitting/hashing, for aggressive caching (especially good behind a HTTP/2 proxy!)
44
+
- Gzip/Brotli minification of static assets.
42
45
- CSS code is combined, minified and optimised automatically - even if you use SASS, LESS and CSS together!
43
46
44
47
### Styles
45
48
46
-
-[Styled Components v4](https://www.styled-components.com/), for writing CSS styles inline and generating the minimal CSS required to properly render your components. Full type inference on themes, too.
49
+
-[Emotion](https://emotion.sh/), for writing CSS styles inline and generating the minimal CSS required to properly render your components.
47
50
-[PostCSS v7](http://postcss.org/) with [next-gen CSS](https://preset-env.cssdb.org/) and automatic vendor prefixing when importing `.css`, `.scss` or `.less` files.
48
51
-[SASS](http://sass-lang.com) and [LESS](http://lesscss.org/) support (also parsed through PostCSS.)
49
52
- Automatic vendor prefixing - write modern CSS, and let the compiler take care of browser compatibility.
50
53
- Mix and match SASS, LESS and regular CSS - without conflicts!
51
54
- CSS modules - your classes are hashed automatically, to avoid namespace conflicts.
52
-
- Compatible with Foundation, Bootstrap, Material and more. Simply configure via a `.global.(css|scss|less)` import to preserve class names.
55
+
- Compatible with Foundation, Bootstrap, Material UI and more. Simply configure via a `.global.(css|scss|less)` import to preserve class names.
53
56
54
57
### Production-ready
55
58
56
59
- Production bundling via `npm run production`, that generates optimised server and client code.
57
60
-[Static compression](https://webpack.js.org/plugins/compression-webpack-plugin/) using the Gzip and [Brotli](https://opensource.googleblog.com/2015/09/introducing-brotli-new-compression.html) algorithms for the serving of static assets as pre-compressed `.gz` and `.br` files (your entire app's `main.js.bz` - including all dependencies - goes from 346kb -> 89kb!)
58
-
- Automatic HTTP hardening against common attack vectors via [Koa Helmet](https://github.com/venables/koa-helmet) (highly configurable)
59
-
- New in v3.5: Static bundling via `npm run static`. Easily deploy a client-only SPA to any static web host (Netlify, etc.)
61
+
- Static bundling via `npm run static`. Don't need server-side rendering? No problem. Easily deploy a client-only SPA to any static web host (Netlify, etc.)
60
62
61
63
### Developer support
62
64
@@ -68,8 +70,8 @@ https://reactql.org
68
70
Grab and unpack the latest version, install all dependencies, and start a server:
69
71
70
72
```
71
-
wget -qO- https://github.com/leebenson/reactql/archive/3.7.1.tar.gz | tar xvz
72
-
cd reactql-3.7.1
73
+
wget -qO- https://github.com/leebenson/reactql/archive/4.0.0.tar.gz | tar xvz
74
+
cd reactql-4.0.0
73
75
npm i
74
76
npm start
75
77
```
@@ -80,11 +82,11 @@ Your development server is now running on [http://localhost:3000](http://localho
80
82
81
83
Development mode offers a few useful features:
82
84
83
-
- Hot code reloading. Make a change anywhere in your code base (outside of the Webpack config), and changes will be pushed down the browser automatically - without page reloads. This happens for React, Styled Components, SASS - pretty much anything.
85
+
- Hot code reloading. Make a change anywhere in your code base (outside of the Webpack config), and changes will be pushed down the browser automatically - without page reloads. This happens for React, Emotion, SASS - pretty much anything.
84
86
85
-
- Full source maps for Javascript and CSS
87
+
- Full source maps for Javascript and CSS.
86
88
87
-
- Full server-side rendering, with automatic Koa web server restarting on code changes. This ensures the initial HTML render will always reflect your latest code changes
89
+
- Full server-side rendering, with automatic Koa web server restarting on code changes. This ensures the initial HTML render will always reflect your latest code changes.
88
90
89
91
To get started, simply run:
90
92
@@ -130,43 +132,37 @@ The important stuff is in [src](src).
130
132
131
133
Here's a quick run-through of each sub-folder and what you'll find in it:
132
134
133
-
-[src/components](src/components) - React components. Follow the import flow at [root.tsx](src/components/root.tsx) to figure out the component render chain. I've included an [example](src/components/example) component that shows off some Apollo GraphQL features, including incrementing a local counter and pulling top news stories from Hacker News (a live GraphQL server endpoint.)
135
+
-[src/components](src/components) - React components. Follow the import flow at [root.tsx](src/components/root.tsx) to figure out the component render chain. I've included an [example](src/components/example) component that shows off some Apollo GraphQL and MobX features, including incrementing a local counter and pulling top news stories from Hacker News (a live GraphQL server endpoint.)
134
136
135
-
-[src/data](src/data) - Data used throughout your app. You'll find [routes.ts](src/data/routes.ts), which defines your React Router routes (currently, just the home page -- but you can easily extend this.)
137
+
-[src/data](src/data) - Data used throughout your app. You'll find [routes.ts](src/data/routes.ts), which defines your React Router routes (currently, just the home page -- but you can easily extend this.) and [state.ts](src/data/state.ts), to show you how simple it is to define your own state data fields that, when modified, automatically re-render any 'observing' component.
136
138
137
139
-[src/entry](src/entry) - The client and server entry points, which call on [src/components/root.tsx](src/components/root.tsx) to isomorphically render the React chain in both environments.
138
140
139
-
-[src/global](src/global) - A good place for anything that's used through your entire app, like global styles. I've started you off with a [styles.ts](src/global/styles.ts) that sets globally inlined Styled Components CSS, as well as pulls in a global `.scss` file -- to show you how both types of CSS work.
140
-
141
-
-[src/graphql](src/graphql) - GraphQL initialisation goes here. There's an [apollo.ts](src/graphql/apollo.ts) which builds a universal Apollo Client and enables local state, and [state.ts](src/graphql/state.ts) which sets up default state (automatically rehydrated on the client) and some mutation handlers, for incrementing a local counter.
141
+
-[src/global](src/global) - A good place for anything that's used through your entire app, like global styles. I've started you off with a [styles.ts](src/global/styles.ts) that sets globally inlined Emotion CSS, as well as pulls in a global `.scss` file -- to show you how both types of CSS work.
142
142
143
-
-[src/lib](src/lib) - Library functions to handle hot-code reloading, finding the right `main.js` / `main.css` in production (which is automatically hashed for versioning), Webpack stats and Styled Components.
143
+
-[src/lib](src/lib) - Internal libraries/helpers. There's an [apollo.ts](src/lib/apollo.ts) which builds a universal Apollo Client, and [mobx.ts](src/graphql/mobx.ts) which sets up default state (automatically rehydrated on the client), for incrementing a local counter. Plus, functions to handle hot-code reloading, Webpack stats helpers (used by the server to automatically load the right `<script>` tags, and some internal stuff to help with hot-code reloading the server when code changes in developmnt.
144
144
145
-
-[src/mutations](src/mutations) - Your GraphQL mutations. Out-the-box, you'll find the query to increment the local state counter.
146
-
147
-
-[src/queries](src/queries) - Your GraphQL queries. There are two by default - one that grabs the local counter state, another that pulls the top stories from Hacker News to display in the example component.
145
+
-[src/queries](src/queries) - Your GraphQL queries. There's just one by default - for pilling the top stories from Hacker News to display in the example component.
148
146
149
147
-[src/runner](src/runner) - Development and production runners that spawn the Webpack build process in each environment.
150
148
151
-
-[src/themes](src/themes) - A sample [interface](src/themes/interface.ts) type for defining a Styled Components theme, and a [default theme](src/themes/default.ts) that's used in the example component to add an orange hover to Hacker News links.
152
-
153
-
-[src/views](src/views) - View components that fall outside of the usual React component chain, for use on the server. In here, [ssr.tsx](src/views/ssr.tsx) takes care of rendering the root HTML that's sent down the wire to the client. Note this is also a React component - your whole app will render as React!
149
+
-[src/views](src/views) - View components that fall outside of the usual React component chain, for use on the server. In here, [ssr.tsx](src/views/ssr.tsx) takes care of rendering the root HTML that's sent down the wire to the client. Note this is also a React component - your whole app will render as React! - and [static.html](src/views/static.html) serves as a template for rendering a client-side SPA. Update it as needed.
154
150
155
151
-[src/webpack](src/webpack) - The Webpack 4 configuration files that do the heavy lifting to transform our Typescript code, images and CSS into optimised and minified assets that wind up in the `dist` folder at the root. Handles both the client and server environments.
156
152
157
153
You'll also find some other useful goodies in the [root]()...
158
154
159
155
-[.env](.env) - Change your `GRAPHQL` server endpoint, and `WS_SUBSCRIPTIONS=1` for built-in WebSocket support.
160
156
161
-
-[.nvmrc](.nvmrc) - Specify your preferred Node.js version, for use with NVM and used by many continuous deployment tools. Defaults to v10.11
157
+
-[.nvmrc](.nvmrc) - Specify your preferred Node.js version, for use with NVM and used by many continuous deployment tools. Defaults to v11.8.0
162
158
163
159
-[netlify.toml](netlify.toml) - Build instructions for fast [Netlify](https://www.netlify.com/) deployments. **Tip: To quickly deploy a demo ReactQL app, [click here](https://app.netlify.com/start/deploy?repository=https://github.com/leebenson/reactql).**
164
160
165
161
-[types](types) - Some basic types that allow you to import fonts, images, CSS/SASS/LESS files, and allow use of the global `SERVER` boolean in your IDE.
166
162
167
-
- Typescript configuration via [tsconfig.json](tsconfig.json) and [tslint.json](tslint.json)
163
+
- Typescript configuration via [tsconfig.json](tsconfig.json)
168
164
169
-
- A sample [Dockerfile](Dockerfile) for quickly deploying your code base to production.
165
+
- A sample multi-build [Dockerfile](Dockerfile) based on Node 11.8 and Alpine, for quickly deploying your code base to production.
0 commit comments