Post nextjs cleanup (#66)
* remove next deps * remove next related files * remove other unused deps * remove more deps + their *.d.ts * add explicit core-js dep (for babel-preset-evn/polyfill) * use abs path for node_modules to limit resolution to package dir
This commit is contained in:
parent
bed95f7f9b
commit
d977d990c4
|
@ -1,57 +0,0 @@
|
|||
import React from 'react';
|
||||
import { AppState } from 'store/reducers';
|
||||
import { configureStore } from 'store/configure';
|
||||
|
||||
const isServer = typeof window === 'undefined';
|
||||
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__';
|
||||
|
||||
function getOrCreateStore(initialState?: Partial<AppState>) {
|
||||
// Always make a new store if server, otherwise state is shared between requests
|
||||
if (isServer) {
|
||||
return configureStore(initialState);
|
||||
}
|
||||
|
||||
// Create store if unavailable on the client and set it on the window object
|
||||
const anyWindow = window as any;
|
||||
if (!anyWindow[__NEXT_REDUX_STORE__]) {
|
||||
anyWindow[__NEXT_REDUX_STORE__] = configureStore(initialState);
|
||||
}
|
||||
return anyWindow[__NEXT_REDUX_STORE__];
|
||||
}
|
||||
|
||||
interface Props {
|
||||
initialReduxState: Partial<AppState>;
|
||||
}
|
||||
|
||||
export default (App: any) => {
|
||||
return class AppWithRedux extends React.Component<Props> {
|
||||
static async getInitialProps(appContext: any) {
|
||||
// Get or Create the store with `undefined` as INITIAL_STATE
|
||||
// This allows you to set a custom default INITIAL_STATE
|
||||
const store = getOrCreateStore();
|
||||
|
||||
// Provide the store to getInitialProps of pages
|
||||
appContext.ctx.store = store;
|
||||
|
||||
let appProps = {};
|
||||
if (typeof App.getInitialProps === 'function') {
|
||||
appProps = await App.getInitialProps.call(App, appContext);
|
||||
}
|
||||
|
||||
return {
|
||||
...appProps,
|
||||
initialReduxState: store.getState(),
|
||||
};
|
||||
}
|
||||
|
||||
private store: any;
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.store = getOrCreateStore(props.initialReduxState);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <App {...this.props} store={this.store} />;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,39 +0,0 @@
|
|||
import App, { Container } from 'next/app';
|
||||
import React from 'react';
|
||||
|
||||
import { Provider } from 'react-redux';
|
||||
import withReduxSaga from 'next-redux-saga';
|
||||
import withReduxStore from 'lib/with-redux-store';
|
||||
|
||||
interface Props {
|
||||
Component: any;
|
||||
ctx: any;
|
||||
}
|
||||
|
||||
class MyApp extends App {
|
||||
static async getInitialProps({ Component, ctx }: Props) {
|
||||
let pageProps = {};
|
||||
|
||||
if (Component.getInitialProps) {
|
||||
pageProps = await Component.getInitialProps(ctx);
|
||||
}
|
||||
|
||||
return { pageProps };
|
||||
}
|
||||
|
||||
props: any;
|
||||
|
||||
render() {
|
||||
const { Component, pageProps, store } = this.props;
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Provider store={store}>
|
||||
<Component {...pageProps} />
|
||||
</Provider>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withReduxStore(withReduxSaga({ async: true })(MyApp));
|
|
@ -1,57 +0,0 @@
|
|||
import React from 'react';
|
||||
import Document, { Head, Main, NextScript } from 'next/document';
|
||||
import { ServerStyleSheet } from 'styled-components';
|
||||
import { ThemeProvider, injectGlobal } from 'styled-components';
|
||||
import theme from '../components/theme';
|
||||
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
injectGlobal`
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
}
|
||||
html {
|
||||
font-size: 16px;
|
||||
|
||||
@media (max-width: 900px) {
|
||||
font-size: 14px;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
}
|
||||
`;
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
static getInitialProps({ renderPage }: { renderPage: (props: any) => void }) {
|
||||
const sheet = new ServerStyleSheet();
|
||||
const page = renderPage((App: any) => (props: any) =>
|
||||
sheet.collectStyles(<App {...props} />),
|
||||
);
|
||||
|
||||
// @ts-ignore
|
||||
const styleTags = sheet.getStyleElement();
|
||||
// @ts-ignore
|
||||
return { ...page, styleTags };
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<html>
|
||||
<Head>
|
||||
<title>My page</title>
|
||||
{this.props.styleTags}
|
||||
</Head>
|
||||
<ThemeProvider theme={theme}>
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</ThemeProvider>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
import React from 'react';
|
||||
declare module 'rc-queue-anim' {
|
||||
export default React.Component;
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
import React from 'react';
|
||||
declare module 'rc-scroll-anim' {
|
||||
export default React.Component;
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
import React from 'react';
|
||||
declare module 'rc-tween-one' {
|
||||
export default React.Component;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
declare module 'isomorphic-unfetch';
|
|
@ -19,6 +19,6 @@ const paths = {
|
|||
srcServer: resolveApp('server'),
|
||||
};
|
||||
|
||||
paths.resolveModules = [paths.srcClient, paths.srcServer, 'node_modules'];
|
||||
paths.resolveModules = [paths.srcClient, paths.srcServer, resolveApp('node_modules')];
|
||||
|
||||
module.exports = paths;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
// moves "export" out dir into root
|
||||
var fs = require('fs-extra');
|
||||
fs.removeSync('out');
|
||||
var spawn = require('child_process').spawn,
|
||||
mv = spawn('mv', ['client/out', 'out']);
|
|
@ -1,76 +0,0 @@
|
|||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||
const { withPlugins } = require('next-compose-plugins');
|
||||
const images = require('next-images');
|
||||
const sass = require('@zeit/next-sass');
|
||||
const css = require('@zeit/next-css');
|
||||
const less = require('@zeit/next-less');
|
||||
const typescript = require('@zeit/next-typescript');
|
||||
|
||||
const nextConfig = {
|
||||
distDir: 'build',
|
||||
webpack: (config, options) => {
|
||||
config.resolve.symlinks = false;
|
||||
config.context = `${__dirname}/client`;
|
||||
|
||||
// Do not run type checking twice:
|
||||
if (options.isServer) {
|
||||
// config.plugins.push(
|
||||
// new ForkTsCheckerWebpackPlugin({
|
||||
// tsconfig: '../tsconfig.json',
|
||||
// tslint: '../tslint.json'
|
||||
// })
|
||||
// );
|
||||
}
|
||||
|
||||
if (process.env.ANALYZE) {
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'server',
|
||||
analyzerPort: 8888,
|
||||
openAnalyzer: true
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
config.module.rules.push({
|
||||
exclude: /node_modules/,
|
||||
loader: 'graphql-tag/loader',
|
||||
test: /\.(graphql|gql)$/
|
||||
});
|
||||
|
||||
config.module.rules.push({
|
||||
test: /\.(eot|otf|ttf|woff|woff2)$/,
|
||||
use: {
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 100000,
|
||||
publicPath: './',
|
||||
outputPath: 'static/',
|
||||
name: '[name].[ext]'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = withPlugins(
|
||||
[
|
||||
sass,
|
||||
images,
|
||||
css,
|
||||
[
|
||||
less,
|
||||
{
|
||||
lessLoaderOptions: {
|
||||
javascriptEnabled: true
|
||||
}
|
||||
}
|
||||
],
|
||||
typescript
|
||||
],
|
||||
nextConfig
|
||||
);
|
||||
|
|
@ -43,22 +43,15 @@
|
|||
"@types/dotenv": "^4.0.3",
|
||||
"@types/express": "^4.16.0",
|
||||
"@types/express-winston": "^3.0.0",
|
||||
"@types/headroom": "^0.7.31",
|
||||
"@types/history": "^4.7.0",
|
||||
"@types/i18next": "^8.4.5",
|
||||
"@types/js-cookie": "2.1.0",
|
||||
"@types/jwt-decode": "^2.2.1",
|
||||
"@types/lodash": "^4.14.112",
|
||||
"@types/next": "^6.1.0",
|
||||
"@types/next-redux-wrapper": "^1.4.1",
|
||||
"@types/node": "^10.3.1",
|
||||
"@types/nprogress": "0.0.29",
|
||||
"@types/numeral": "^0.0.25",
|
||||
"@types/react": "16.3.16",
|
||||
"@types/react-document-title": "^2.0.2",
|
||||
"@types/react-dom": "^16.0.6",
|
||||
"@types/react-helmet": "^5.0.7",
|
||||
"@types/react-i18next": "^7.8.2",
|
||||
"@types/react-redux": "^6.0.2",
|
||||
"@types/react-router": "^4.0.31",
|
||||
"@types/react-router-dom": "^4.3.1",
|
||||
|
@ -68,33 +61,24 @@
|
|||
"@types/webpack": "^4.4.11",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@types/winston": "^2.4.4",
|
||||
"@zeit/next-css": "^0.2.0",
|
||||
"@zeit/next-less": "^0.3.0",
|
||||
"@zeit/next-sass": "^0.2.0",
|
||||
"@zeit/next-typescript": "^1.1.0",
|
||||
"ant-design-pro": "^2.0.0-beta.2",
|
||||
"antd": "^3.7.1",
|
||||
"axios": "^0.18.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-loader": "^8.0.2",
|
||||
"babel-plugin-dynamic-import-node": "^2.1.0",
|
||||
"babel-plugin-dynamic-import-webpack": "^1.0.2",
|
||||
"babel-plugin-import": "^1.8.0",
|
||||
"babel-plugin-inline-dotenv": "^1.1.2",
|
||||
"babel-plugin-module-resolver": "^3.1.1",
|
||||
"babel-plugin-styled-components": "^1.5.1",
|
||||
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
||||
"babel-register": "^6.26.0",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"bn.js": "4.11.8",
|
||||
"body-parser": "^1.18.3",
|
||||
"chalk": "^2.4.1",
|
||||
"cookie-parser": "^1.4.3",
|
||||
"core-js": "^2.5.7",
|
||||
"cors": "^2.8.4",
|
||||
"cross-env": "^5.2.0",
|
||||
"css-loader": "^1.0.0",
|
||||
"dotenv": "^6.0.0",
|
||||
"drizzle": "^1.2.2",
|
||||
"ethereum-blockies-base64": "1.0.2",
|
||||
"ethereumjs-util": "5.2.0",
|
||||
"express": "^4.16.3",
|
||||
|
@ -107,11 +91,7 @@
|
|||
"fs-extra": "^7.0.0",
|
||||
"http-proxy-middleware": "^0.18.0",
|
||||
"husky": "^1.0.0-rc.8",
|
||||
"i18next": "^11.9.0",
|
||||
"is-mobile": "^1.0.0",
|
||||
"isomorphic-unfetch": "^2.0.0",
|
||||
"js-cookie": "^2.2.0",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"less": "^3.7.1",
|
||||
"less-loader": "^4.1.0",
|
||||
"lint-staged": "^7.2.2",
|
||||
|
@ -119,29 +99,16 @@
|
|||
"lodash": "^4.17.10",
|
||||
"mini-css-extract-plugin": "^0.4.2",
|
||||
"moment": "^2.22.2",
|
||||
"next": "^6.1.1",
|
||||
"next-compose-plugins": "^2.1.1",
|
||||
"next-images": "^0.10.5",
|
||||
"next-redux-saga": "^3.0.0-beta.1",
|
||||
"next-redux-wrapper": "^2.0.0-beta.6",
|
||||
"next-routes": "^1.4.2",
|
||||
"node-sass": "^4.9.2",
|
||||
"nodemon": "^1.18.4",
|
||||
"nprogress": "^0.2.0",
|
||||
"openzeppelin-solidity": "^1.12.0",
|
||||
"prettier": "^1.13.4",
|
||||
"prettier-package-json": "^1.6.0",
|
||||
"rc-queue-anim": "^1.4.0",
|
||||
"rc-scroll-anim": "^2.0.2",
|
||||
"rc-tween-one": "^1.5.5",
|
||||
"react": "^16.4.0",
|
||||
"react-dev-utils": "^5.0.2",
|
||||
"react-document-title": "^2.0.3",
|
||||
"react-dom": "^16.4.0",
|
||||
"react-headroom": "^2.2.2",
|
||||
"react-helmet": "^5.2.0",
|
||||
"react-hot-loader": "^4.3.8",
|
||||
"react-i18next": "^7.12.0",
|
||||
"react-mde": "^5.8.0",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-router": "^4.3.1",
|
||||
|
@ -154,12 +121,9 @@
|
|||
"redux-saga": "^0.16.0",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"showdown": "^1.8.6",
|
||||
"slate": "^0.37.3",
|
||||
"slate-react": "^0.15.4",
|
||||
"stats-webpack-plugin": "^0.7.0",
|
||||
"style-loader": "^0.23.0",
|
||||
"styled-components": "^3.4.6",
|
||||
"truffle-hdwallet-provider": "0.0.6",
|
||||
"ts-loader": "^5.1.1",
|
||||
"tslint": "^5.10.0",
|
||||
"tslint-config-airbnb": "^5.9.2",
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
const routes = require('next-routes');
|
||||
|
||||
module.exports = routes()
|
||||
.add('clock')
|
||||
.add('createProposal', '/proposals/new', 'editor')
|
||||
.add('proposal', '/proposals/:id', 'proposal')
|
||||
.add('proposals');
|
|
@ -1,71 +0,0 @@
|
|||
/* eslint-disable no-console */
|
||||
const express = require('express');
|
||||
const next = require('next');
|
||||
const cookieParser = require('cookie-parser');
|
||||
|
||||
const routes = require('./routes');
|
||||
|
||||
// const devProxy = {
|
||||
// '/api': {
|
||||
// target: 'http://localhost:5000/api/',
|
||||
// pathRewrite: { '^/api': '/' },
|
||||
// changeOrigin: true
|
||||
// }
|
||||
// };
|
||||
|
||||
const port = parseInt(process.env.PORT, 10) || 3000;
|
||||
const env = process.env.NODE_ENV;
|
||||
const dev = env !== 'production';
|
||||
const app = next({
|
||||
dir: 'client', // base directory where everything is, could move to client later
|
||||
dev
|
||||
});
|
||||
const handler = routes.getRequestHandler(app);
|
||||
|
||||
let server;
|
||||
app
|
||||
.prepare()
|
||||
.then(() => {
|
||||
server = express();
|
||||
|
||||
// Set up the proxy.
|
||||
// if (dev && devProxy) {
|
||||
// const proxyMiddleware = require('http-proxy-middleware');
|
||||
// Object.keys(devProxy).forEach(function(context) {
|
||||
// server.use(proxyMiddleware(context, devProxy[context]));
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// server.use(cookieParser());
|
||||
//
|
||||
//
|
||||
// server.get('/login', (req, res) => {
|
||||
// if(req.cookies.token) {
|
||||
// res.redirect('/');
|
||||
// } else {
|
||||
// return app.render(req, res, '/login', req.query);
|
||||
// }
|
||||
// });
|
||||
|
||||
// server.get('/signup', (req, res) => {
|
||||
// if(req.cookies.token) {
|
||||
// res.redirect('/');
|
||||
// } else {
|
||||
// return app.render(req, res, '/signup', req.query);
|
||||
// }
|
||||
// });
|
||||
|
||||
// Default catch-all handler to allow Next.js to handle all other routes
|
||||
server.all('*', (req, res) => handler(req, res));
|
||||
|
||||
server.listen(port, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log(`> Ready on port ${port}`);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('An error occurred, unable to start the server');
|
||||
console.log(err);
|
||||
});
|
3924
frontend/yarn.lock
3924
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue