Skip to content

Commit

Permalink
Fix production build (#265)
Browse files Browse the repository at this point in the history
* Fix production build

The production build failing was the result of a bug related to an older version react-scripts not playing nice with the latest version of graphql (graphql/graphql-js#1248).

Updating to the latest version of react-scripts (v2.1.1) fixed the bug. It also reduces the production build *considerably* (from over 1mb down to 48kb).

* Downgrade babel-preset-react-app to 3.1.0
  • Loading branch information
adamsoffer authored and Randy1Burrell committed Dec 7, 2018
1 parent 751636b commit 24364a7
Show file tree
Hide file tree
Showing 15 changed files with 7,036 additions and 2,884 deletions.
2 changes: 1 addition & 1 deletion docs/explorer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This project is bootstrapped with [create-react-app](https://github.com/facebook

| Directory | Description |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `.` | config files: .prettierrc, .gitignore, webpack.config.prod.js, package.json, README.md, etc |
| `.` | config files: .prettierrc, .gitignore, package.json, README.md, etc |
| `public/.` | assets (images, fonts, etc) go here |
| `public/index.html` | the app's html entrypoint |
| `src/index.js` | the app's js entrypoint |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"release:alpha":
"npx lerna publish --cd-version prerelease --conventional-commits --yes",
"test":
"npx lerna run test --ignore @livepeer/explorer --ignore @livepeer/player",
"npx lerna run test --ignore @livepeer/explorer --ignore @livepeer/player --ignore @livepeer/chroma",
"updated": "npx lerna updated --json"
},
"devDependencies": {
Expand Down
17 changes: 7 additions & 10 deletions packages/apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@
"prepack": "npm -s run build",
"test": "npx ava"
},
"peerDependencies": {
"@livepeer/graphql-sdk": "^1.0.0-alpha.3",
"@livepeer/sdk": "^1.0.0-alpha.3",
"apollo-cache-inmemory": "1.1.10",
"apollo-client": "2.2.6",
"apollo-link": "1.2.1",
"babel-runtime": "^6.26.0",
"graphql": "14.0.0"
},
"devDependencies": {
"ava": "0.25.0",
"babel-cli": "^6.26.0",
Expand All @@ -33,6 +24,7 @@
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"express": "4.16.3",
"express-graphql": "0.6.12"
},
Expand All @@ -44,10 +36,15 @@
"babel": "inherit"
},
"dependencies": {
"@livepeer/graphql-sdk": "^1.0.0-alpha.5",
"@livepeer/sdk": "^1.0.0-alpha.5",
"apollo-cache-inmemory": "^1.3.11",
"apollo-cache-persist": "^0.1.1",
"apollo-client": "2.2.6",
"apollo-client": "^2.4.7",
"apollo-link-http": "^1.5.5",
"apollo-link-state": "^0.4.1",
"apollo-link": "^1.2.4",
"graphql": "^14.0.2",
"graphql-tools": "^4.0.0",
"node-fetch": "^2.2.0"
}
Expand Down
11 changes: 3 additions & 8 deletions packages/apollo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ import { graphql, parse, print, subscribe } from 'graphql'
import Livepeer from '@livepeer/sdk'
import { schema, introspectionQueryResultData } from '@livepeer/graphql-sdk'
import {
makeExecutableSchema,
introspectSchema,
makeRemoteExecutableSchema,
mergeSchemas,
transformSchema,
RenameTypes,
RenameRootFields,
} from 'graphql-tools'
import { onError } from 'apollo-link-error'
import { HttpLink } from 'apollo-link-http'
import fetch from 'node-fetch'
import axios from 'axios'

type OnAccountChangeCallback = (
Expand Down Expand Up @@ -110,7 +104,6 @@ export default async function createApolloClient(

const subgraphServiceLink = new HttpLink({
uri: options.livepeerSubgraph,
fetch,
})

const createSubgraphServiceSchema = async () => {
Expand All @@ -134,6 +127,9 @@ export default async function createApolloClient(
* @return {boolean}
*/
async function isSubgraphAvailable(url: string): boolean {
if (!url) {
return false
}
try {
await axios({
url,
Expand All @@ -150,7 +146,6 @@ export default async function createApolloClient(
})
return true
} catch (e) {
console.log(e)
return false
}
}
Expand Down
12 changes: 3 additions & 9 deletions packages/chroma/src/VideoPlayer/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ exports[`should render as expected 1`] = `
muted=""
playsinline=""
preload="auto"
>
</video>
/>
<button
aria-live="polite"
class="video-react-big-play-button video-react-big-play-button-center big-play-button-hide"
Expand Down Expand Up @@ -65,9 +63,7 @@ exports[`should render as expected 1`] = `
>
<span
class="video-react-control-text"
>
</span>
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -162,9 +158,7 @@ exports[`should render as expected 1`] = `
<button
class="video-react-icon video-react-control video-react-button video-react-icon-settings"
tabindex="0"
>
</button>
/>
</div>
<button
class="video-react-icon-fullscreen video-react-fullscreen-control video-react-control video-react-button video-react-icon"
Expand Down
12 changes: 6 additions & 6 deletions packages/explorer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ A protocol explorer for the web. It allows users to see general information abou

## Table of Contents

* [Installation](#installation)
* [Developing](#developing)
* [Building](#building)
- [Installation](#installation)
- [Developing](#developing)
- [Building](#building)

<!-- hide-on-docup-stop -->

Expand Down Expand Up @@ -61,7 +61,7 @@ This project is bootstrapped with [create-react-app](https://github.com/facebook

| Directory | Description |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `.` | config files: .prettierrc, .gitignore, webpack.config.prod.js, package.json, README.md, etc |
| `.` | config files: .prettierrc, .gitignore, package.json, README.md, etc |
| `public/.` | assets (images, fonts, etc) go here |
| `public/index.html` | the app's html entrypoint |
| `src/index.js` | the app's js entrypoint |
Expand All @@ -79,8 +79,8 @@ This project is bootstrapped with [create-react-app](https://github.com/facebook

You can build this app as a website or as a desktop app (via `electron`).

* **Website:** `yarn build:web` (outputs to `./build`)
* **Desktop:** `yarn build:desktop` (outputs to `./dist`)
- **Website:** `yarn build:web` (outputs to `./build`)
- **Desktop:** `yarn build:desktop` (outputs to `./dist`)

**Note:** Only the OSX desktop build has been configured. If you would like to add a configuration for linux or windows, please modify the config accordingly in [package.json](https://github.com/livepeer/livepeerjs/blob/master/packages/explorer/package.json#L45), and [file a PR](https://github.com/livepeer/livepeerjs/pulls) 🍻

Expand Down
21 changes: 13 additions & 8 deletions packages/explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"big.js": "^5.0.3",
"bn.js": "^4.11.8",
"final-form": "^4.2.1",
"graphql": "14.0.0",
"graphql-tag": "2.8.0",
"graphql": "^14.0.2",
"graphql-tag": "^2.8.0",
"qrcode-react": "^0.1.16",
"query-string": "^5.0.1",
"react": "^16.2.0",
Expand All @@ -31,7 +31,7 @@
"react-redux": "5.0.7",
"react-router-dom": "^4.2.2",
"react-router-redux": "^5.0.0-alpha.8",
"react-scripts": "1.1.1",
"react-scripts": "^2.1.1",
"react-tooltip": "^3.5.0",
"react-transition-group": "^2.2.1",
"recompose": "^0.26.0",
Expand All @@ -53,11 +53,10 @@
"coverage": "npx react-scripts test --env=jsdom --coverage",
"deploy": "npx poosh",
"eject": "npx react-scripts eject",
"postbuild": "cp build/index.html build/404.html && npx uglify-es build/static/js/main.*.js -c -m -o build/static/js/$(ls build/static/js | head -n 1)",
"prebuild": "cp webpack.config.prod.js ../../node_modules/react-scripts/config",
"postbuild": "cp build/index.html build/404.html",
"serve": "npx serve -s build",
"start": "npx react-scripts start",
"test": "npx react-scripts test --env=jsdom"
"test": "npx react-scripts test"
},
"build": {
"appId": "org.livepeer.livepeer-protocol-explorer",
Expand All @@ -77,7 +76,13 @@
"gh-pages": "^1.1.0",
"poosh-cli": "^2.0.0",
"poosh-plugin-s3": "^2.0.0",
"serve": "6.5.3",
"serve": "^10.1.1",
"uglify-es": "^3.2.0"
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Loading

0 comments on commit 24364a7

Please sign in to comment.