From f2daafadfb21fc2b80aee4805b470fe26065973d Mon Sep 17 00:00:00 2001 From: MICHAEL JACKSON Date: Thu, 14 Dec 2017 08:21:45 -0800 Subject: [PATCH] Remove CRA stuff, revert to custom webpack config --- client/.babelrc | 4 + client/.eslintrc | 14 + client/NumberTextInput.js | 44 - client/index.html | 10 + client/index.js | 2 +- config/env.js | 38 - config/jest/cssTransform.js | 14 - config/jest/fileTransform.js | 12 - config/paths.js | 78 - config/polyfills.js | 16 - config/webpack.config.dev.js | 214 -- config/webpack.config.prod.js | 238 -- package.json | 78 +- scripts/build.js | 199 -- scripts/start.js | 338 -- scripts/test.js | 20 - server/.eslintrc | 17 + server/__tests__/.eslintrc | 5 + server/actions/removeFromBlacklist.js | 1 - server/createServer.js | 4 +- server/middleware/serveFile.js | 2 +- server/middleware/utils/.eslintrc | 5 + server/middleware/utils/__tests__/.eslintrc | 5 + server/middleware/utils/getPackage.js | 2 +- server/utils/__tests__/.eslintrc | 5 + server/utils/parsePackageURL.js | 2 +- webpack.config.js | 49 + yarn.lock | 3171 ++++++++++++------- 28 files changed, 2097 insertions(+), 2490 deletions(-) create mode 100644 client/.babelrc create mode 100644 client/.eslintrc delete mode 100644 client/NumberTextInput.js create mode 100644 client/index.html delete mode 100644 config/env.js delete mode 100644 config/jest/cssTransform.js delete mode 100644 config/jest/fileTransform.js delete mode 100644 config/paths.js delete mode 100644 config/polyfills.js delete mode 100644 config/webpack.config.dev.js delete mode 100644 config/webpack.config.prod.js delete mode 100644 scripts/build.js delete mode 100644 scripts/start.js delete mode 100644 scripts/test.js create mode 100644 server/.eslintrc create mode 100644 server/__tests__/.eslintrc create mode 100644 server/middleware/utils/.eslintrc create mode 100644 server/middleware/utils/__tests__/.eslintrc create mode 100644 server/utils/__tests__/.eslintrc create mode 100644 webpack.config.js diff --git a/client/.babelrc b/client/.babelrc new file mode 100644 index 0000000..b1cd9b7 --- /dev/null +++ b/client/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["env", "react", "stage-2"], + "plugins": [] +} diff --git a/client/.eslintrc b/client/.eslintrc new file mode 100644 index 0000000..0dab6bf --- /dev/null +++ b/client/.eslintrc @@ -0,0 +1,14 @@ +{ + "parser": "babel-eslint", + "env": { + "browser": true + }, + "extends": [ + "eslint:recommended", + "plugin:import/errors", + "plugin:react/recommended" + ], + "rules": { + "react/no-children-prop": 0 + } +} diff --git a/client/NumberTextInput.js b/client/NumberTextInput.js deleted file mode 100644 index fa25c43..0000000 --- a/client/NumberTextInput.js +++ /dev/null @@ -1,44 +0,0 @@ -import React from "react" -import PropTypes from "prop-types" -import { parseNumber, formatNumber } from "./NumberUtils" - -class NumberTextInput extends React.Component { - static propTypes = { - value: PropTypes.number, - parseNumber: PropTypes.func, - formatNumber: PropTypes.func, - onChange: PropTypes.func - } - - static defaultProps = { - value: 0, - parseNumber, - formatNumber - } - - state = { - value: null - } - - componentWillMount() { - this.setState({ value: this.props.value }) - } - - handleChange = event => { - const value = this.props.parseNumber(event.target.value) - - this.setState({ value }, () => { - if (this.props.onChange) this.props.onChange(value) - }) - } - - render() { - const { value } = this.state - const { parseNumber, formatNumber, ...props } = this.props // eslint-disable-line no-unused-vars - const displayValue = formatNumber(value) - - return - } -} - -export default NumberTextInput diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..42a4957 --- /dev/null +++ b/client/index.html @@ -0,0 +1,10 @@ + + + + + <%= htmlWebpackPlugin.options.title %> + + +
+ + diff --git a/client/index.js b/client/index.js index 7d59f5e..7f3b43b 100644 --- a/client/index.js +++ b/client/index.js @@ -3,4 +3,4 @@ import ReactDOM from "react-dom" import App from "./App" import "./index.css" -ReactDOM.render(, document.getElementById("root")) +ReactDOM.render(, document.getElementById("app")) diff --git a/config/env.js b/config/env.js deleted file mode 100644 index e2486d7..0000000 --- a/config/env.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict" - -// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be -// injected into the application via DefinePlugin in Webpack configuration. - -var REACT_APP = /^REACT_APP_/i - -function getClientEnvironment(publicUrl) { - var raw = Object.keys(process.env) - .filter(key => REACT_APP.test(key)) - .reduce( - (env, key) => { - env[key] = process.env[key] - return env - }, - { - // Useful for determining whether we’re running in production mode. - // Most importantly, it switches React into the correct mode. - NODE_ENV: process.env.NODE_ENV || "development", - // Useful for resolving the correct path to static assets in `public`. - // For example, . - // This should only be used as an escape hatch. Normally you would put - // images into the `src` and `import` them in code to get their paths. - PUBLIC_URL: publicUrl - } - ) - // Stringify all values so we can feed into Webpack DefinePlugin - var stringified = { - "process.env": Object.keys(raw).reduce((env, key) => { - env[key] = JSON.stringify(raw[key]) - return env - }, {}) - } - - return { raw, stringified } -} - -module.exports = getClientEnvironment diff --git a/config/jest/cssTransform.js b/config/jest/cssTransform.js deleted file mode 100644 index 198fb60..0000000 --- a/config/jest/cssTransform.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict" - -// This is a custom Jest transformer turning style imports into empty objects. -// http://facebook.github.io/jest/docs/tutorial-webpack.html - -module.exports = { - process() { - return "module.exports = {};" - }, - getCacheKey() { - // The output is always the same. - return "cssTransform" - } -} diff --git a/config/jest/fileTransform.js b/config/jest/fileTransform.js deleted file mode 100644 index fdc72d7..0000000 --- a/config/jest/fileTransform.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict" - -const path = require("path") - -// This is a custom Jest transformer turning file imports into filenames. -// http://facebook.github.io/jest/docs/tutorial-webpack.html - -module.exports = { - process(src, filename) { - return "module.exports = " + JSON.stringify(path.basename(filename)) + ";" - } -} diff --git a/config/paths.js b/config/paths.js deleted file mode 100644 index a79fda1..0000000 --- a/config/paths.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict" - -var path = require("path") -var fs = require("fs") -var url = require("url") - -// Make sure any symlinks in the project folder are resolved: -// https://github.com/facebookincubator/create-react-app/issues/637 -var appDirectory = fs.realpathSync(process.cwd()) -function resolveApp(relativePath) { - return path.resolve(appDirectory, relativePath) -} - -// We support resolving modules according to `NODE_PATH`. -// This lets you use absolute paths in imports inside large monorepos: -// https://github.com/facebookincubator/create-react-app/issues/253. - -// It works similar to `NODE_PATH` in Node itself: -// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders - -// We will export `nodePaths` as an array of absolute paths. -// It will then be used by Webpack configs. -// Jest doesn’t need this because it already handles `NODE_PATH` out of the box. - -// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. -// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. -// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 - -var nodePaths = (process.env.NODE_PATH || "") - .split(process.platform === "win32" ? ";" : ":") - .filter(Boolean) - .filter(folder => !path.isAbsolute(folder)) - .map(resolveApp) - -var envPublicUrl = process.env.PUBLIC_URL - -function ensureSlash(path, needsSlash) { - var hasSlash = path.endsWith("/") - if (hasSlash && !needsSlash) { - return path.substr(path, path.length - 1) - } else if (!hasSlash && needsSlash) { - return path + "/" - } else { - return path - } -} - -function getPublicUrl(appPackageJson) { - return envPublicUrl || require(appPackageJson).homepage -} - -// We use `PUBLIC_URL` environment variable or "homepage" field to infer -// "public path" at which the app is served. -// Webpack needs to know it to put the right