migrate to babel 7, webpack 4, dep updates, lots

This commit is contained in:
willyb321
2018-09-29 07:49:04 +10:00
parent 59d38cbd33
commit 06dc110025
8 changed files with 6752 additions and 7097 deletions

View File

@@ -1,3 +1,34 @@
{ {
"presets": ["env", "react", "stage-0"] "presets": [
["@babel/preset-env", {"modules": "commonjs"}],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
["@babel/plugin-proposal-class-properties", { "loose": true }],
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-optional-chaining",
[
"@babel/plugin-proposal-pipeline-operator",
{
"proposal": "minimal"
}
],
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-do-expressions",
"@babel/plugin-proposal-function-bind"
]
} }

13441
d3.js vendored

File diff suppressed because it is too large Load Diff

4
d3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,126 +1,144 @@
{ {
"name": "coriolis_shipyard", "name": "coriolis_shipyard",
"version": "3.0.0", "version": "3.0.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/EDCD/coriolis" "url": "https://github.com/EDCD/coriolis"
}, },
"homepage": "https://coriolis.edcd.io", "homepage": "https://coriolis.edcd.io",
"bugs": "https://github.com/EDCD/coriolis/issues", "bugs": "https://github.com/EDCD/coriolis/issues",
"private": true, "private": true,
"engine": "node >= 4.8.1", "engine": "node >= 4.8.1",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"prepublish": "rollup -c && uglifyjs d3.js -c -m -o d3.min.js", "prepublish": "rollup -c && uglifyjs d3.js -c -m -o d3.min.js",
"extract-translations": "grep -hroE \"(translate\\('[^']+'\\))|(tip.bind\\(null, '[^']+')\" src/* | grep -oE \"'[^']+'\" | grep -oE \"[^']+\" | sort -u -f", "extract-translations": "grep -hroE \"(translate\\('[^']+'\\))|(tip.bind\\(null, '[^']+')\" src/* | grep -oE \"'[^']+'\" | grep -oE \"[^']+\" | sort -u -f",
"clean": "rimraf build", "clean": "rimraf build",
"start": "node devServer.js", "start": "node devServer.js",
"lint": "eslint --ext .js,.jsx src", "lint": "eslint --ext .js,.jsx src",
"test": "jest", "test": "jest",
"prod-serve": "nginx -p $(pwd) -c nginx.conf", "prod-serve": "nginx -p $(pwd) -c nginx.conf",
"prod-stop": "kill -QUIT $(cat nginx.pid)", "prod-stop": "kill -QUIT $(cat nginx.pid)",
"build": "npm run clean && cross-env NODE_ENV=production webpack -p --config webpack.config.prod.js", "build": "npm run clean && cross-env NODE_ENV=production webpack -p --config webpack.config.prod.js",
"rsync": "rsync -ae \"ssh -i $CORIOLIS_PEM\" --delete build/ $CORIOLIS_USER@$CORIOLIS_HOST:~/wwws", "rsync": "rsync -ae \"ssh -i $CORIOLIS_PEM\" --delete build/ $CORIOLIS_USER@$CORIOLIS_HOST:~/wwws",
"deploy": "npm run lint && npm test && npm run build && npm run rsync" "deploy": "npm run lint && npm test && npm run build && npm run rsync"
}, },
"jest": { "jest": {
"transform": { "transform": {
".*": "<rootDir>/node_modules/babel-jest" ".*": "<rootDir>/node_modules/babel-jest"
}, },
"testRegex": "(/__tests__/test-.*|\\.(test|spec))\\.js$", "testRegex": "(/__tests__/test-.*|\\.(test|spec))\\.js$",
"moduleFileExtensions": [ "moduleFileExtensions": [
"js", "js",
"json", "json",
"jsx" "jsx"
], ],
"automock": true, "automock": true,
"bail": false, "bail": false,
"unmockedModulePathPatterns": [ "unmockedModulePathPatterns": [
"<rootDir>/node_modules/lodash", "<rootDir>/node_modules/lodash",
"<rootDir>/node_modules/react", "<rootDir>/node_modules/react",
"<rootDir>/node_modules/react-dom", "<rootDir>/node_modules/react-dom",
"<rootDir>/node_modules/react-transition-group", "<rootDir>/node_modules/react-transition-group",
"<rootDir>/node_modules/react-testutils-additions", "<rootDir>/node_modules/react-testutils-additions",
"<rootDir>/node_modules/fbjs", "<rootDir>/node_modules/fbjs",
"<rootDir>/node_modules/fbemitter", "<rootDir>/node_modules/fbemitter",
"<rootDir>/node_modules/classnames", "<rootDir>/node_modules/classnames",
"<rootDir>/node_modules/d3", "<rootDir>/node_modules/d3",
"<rootDir>/node_modules/lz-string", "<rootDir>/node_modules/lz-string",
"<rootDir>/node_modules/jsen", "<rootDir>/node_modules/jsen",
"coriolis-data", "coriolis-data",
"<rootDir>/src/app/shipyard", "<rootDir>/src/app/shipyard",
"<rootDir>/src/app/i18n", "<rootDir>/src/app/i18n",
"<rootDir>/src/app/utils", "<rootDir>/src/app/utils",
"<rootDir>/src/schemas", "<rootDir>/src/schemas",
"<rootDir>/__tests__" "<rootDir>/__tests__"
] ]
}, },
"devDependencies": { "devDependencies": {
"appcache-webpack-plugin": "^1.3.0", "@babel/core": "^7.0.0",
"babel-core": "*", "@babel/plugin-proposal-class-properties": "^7.0.0",
"babel-eslint": "*", "@babel/plugin-proposal-decorators": "^7.0.0",
"babel-jest": "*", "@babel/plugin-proposal-do-expressions": "^7.0.0",
"babel-loader": "*", "@babel/plugin-proposal-export-default-from": "^7.0.0",
"babel-preset-env": "*", "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"babel-preset-react": "*", "@babel/plugin-proposal-function-bind": "^7.0.0",
"babel-preset-stage-0": "*", "@babel/plugin-proposal-function-sent": "^7.0.0",
"create-react-class": "^15.6.2", "@babel/plugin-proposal-json-strings": "^7.0.0",
"cross-env": "^5.1.4", "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"css-loader": "^0.28.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"d3-selection": "1", "@babel/plugin-proposal-numeric-separator": "^7.0.0",
"esdoc": "^1.1.0", "@babel/plugin-proposal-optional-chaining": "^7.0.0",
"esdoc-custom-theme": "^1.4.2", "@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"esdoc-ecmascript-proposal-plugin": "^1.0.0", "@babel/plugin-proposal-throw-expressions": "^7.0.0",
"esdoc-jsx-plugin": "^1.0.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0",
"esdoc-publish-html-plugin": "^1.1.2", "@babel/plugin-syntax-import-meta": "^7.0.0",
"esdoc-react-plugin": "^1.0.1", "@babel/preset-env": "^7.0.0",
"esdoc-standard-plugin": "^1.0.0", "@babel/preset-react": "^7.0.0",
"eslint": "3.19.0", "appcache-webpack-plugin": "^1.4.0",
"eslint-plugin-react": "^6.10.3", "babel-core": "^7.0.0-bridge.0",
"expose-loader": "^0.7.3", "babel-eslint": "^10.0.1",
"express": "^4.15.2", "babel-jest": "^23.6.0",
"extract-text-webpack-plugin": "2.1.0", "babel-loader": "^8.0.0",
"file-loader": "^0.11.1", "copy-webpack-plugin": "^4.5.2",
"html-webpack-plugin": "^2.28.0", "create-react-class": "^15.6.3",
"jest-cli": "^21.2.1", "cross-env": "^5.2.0",
"jsen": "^0.6.4", "css-loader": "^1.0.0",
"json-loader": "^0.5.4", "d3-selection": "^1.3.2",
"less": "^2.7.2", "esdoc": "^1.1.0",
"less-loader": "^4.0.3", "esdoc-custom-theme": "^1.4.2",
"react-addons-perf": "^15.4.2", "esdoc-ecmascript-proposal-plugin": "^1.0.0",
"react-container-dimensions": "^1.4.1", "esdoc-jsx-plugin": "^1.0.0",
"react-testutils-additions": "^15.2.0", "esdoc-publish-html-plugin": "^1.1.2",
"react-transition-group": "^1.1.2", "esdoc-react-plugin": "^1.0.1",
"rimraf": "^2.6.1", "esdoc-standard-plugin": "^1.0.0",
"rollup": "0.41", "eslint": "^5.6.0",
"rollup-plugin-node-resolve": "3", "eslint-plugin-react": "^7.11.1",
"style-loader": "^0.16.1", "expose-loader": "^0.7.5",
"uglify-js": "^2.4.11", "express": "^4.16.3",
"url-loader": "^0.5.8", "extract-text-webpack-plugin": "^4.0.0-beta.0",
"webpack": "^2.4.1", "file-loader": "^2.0.0",
"webpack-bugsnag-plugins": "^1.1.1", "html-webpack-plugin": "^3.0.7",
"webpack-dev-server": "^2.4.4", "jest-cli": "^23.6.0",
"webpack-notifier": "^1.6.0", "jsen": "^0.6.4",
"workbox-webpack-plugin": "^3.4.1" "json-loader": "^0.5.4",
}, "less": "^3.8.1",
"dependencies": { "less-loader": "^4.1.0",
"babel-polyfill": "*", "react-addons-perf": "^15.4.2",
"browserify-zlib-next": "^1.0.1", "react-container-dimensions": "^1.4.1",
"classnames": "^2.2.5", "react-testutils-additions": "^16.0.0",
"coriolis-data": "../coriolis-data", "react-transition-group": "^2.5.0",
"d3": "4.8.0", "rimraf": "^2.6.1",
"detect-browser": "^1.7.0", "rollup": "^0.66.2",
"fbemitter": "^2.1.1", "rollup-plugin-node-resolve": "^3.4.0",
"lodash": "^4.17.10", "style-loader": "^0.23.0",
"lz-string": "^1.4.4", "uglify-js": "^3.4.9",
"pako": "^1.0.6", "url-loader": "^1.1.1",
"prop-types": "^15.5.8", "webpack": "^4.20.2",
"react": "^15.5.4", "webpack-bugsnag-plugins": "^1.2.2",
"react-dom": "^15.5.4", "webpack-cli": "^3.1.1",
"react-extras": "^0.7.1", "webpack-dev-server": "^3.1.9",
"react-ga": "^2.5.3", "webpack-notifier": "^1.6.0",
"react-number-editor": "Athanasius/react-number-editor.git#miggy", "workbox-webpack-plugin": "^3.6.1"
"recharts": "^0.22.3", },
"superagent": "^3.5.2" "dependencies": {
} "@babel/polyfill": "^7.0.0",
} "browserify-zlib-next": "^1.0.1",
"classnames": "^2.2.6",
"coriolis-data": "../coriolis-data",
"d3": "^5.7.0",
"detect-browser": "^3.0.1",
"fbemitter": "^2.1.1",
"lodash": "^4.17.11",
"lz-string": "^1.4.4",
"pako": "^1.0.6",
"prop-types": "^15.6.2",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-extras": "^0.7.1",
"react-ga": "^2.5.3",
"react-number-editor": "Athanasius/react-number-editor.git#miggy",
"recharts": "^1.2.0",
"superagent": "^3.8.3"
}
}

View File

@@ -1,4 +1,3 @@
import 'babel-polyfill';
import React from 'react'; import React from 'react';
import { render } from 'react-dom'; import { render } from 'react-dom';
import '../less/app.less'; import '../less/app.less';

View File

@@ -65,7 +65,6 @@
</head> </head>
<body style="background-color:#000;"> <body style="background-color:#000;">
<section id="coriolis"></section> <section id="coriolis"></section>
<script src="<%= htmlWebpackPlugin.files.chunks.lib.entry %>" charset="utf-8" crossorigin="anonymous"></script>
<script src="<%= htmlWebpackPlugin.files.chunks.app.entry %>" charset="utf-8" crossorigin="anonymous"></script>
</body> </body>
</html> </html>

View File

@@ -1,49 +1,44 @@
const path = require('path'); const path = require('path');
const exec = require('child_process').exec;
const webpack = require('webpack'); const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier'); const WebpackNotifierPlugin = require('webpack-notifier');
const pkgJson = require('./package'); const pkgJson = require('./package');
const buildDate = new Date(); const buildDate = new Date();
function CopyDirPlugin(source, destination) { const CopyWebpackPlugin = require('copy-webpack-plugin');
this.source = source;
this.destination = destination;
}
CopyDirPlugin.prototype.apply = function(compiler) {
compiler.plugin('done', () => {
console.log(compiler.outputPath, this.destination);
exec('cp -r ' + this.source + ' ' + path.join(compiler.outputPath, this.destination));
});
};
module.exports = { module.exports = {
devtool: 'source-map', devtool: 'source-map',
devServer: { devServer: {
headers: { 'Access-Control-Allow-Origin': '*' } headers: { 'Access-Control-Allow-Origin': '*' }
}, },
mode: 'development',
entry: { entry: {
app: ['webpack-dev-server/client?http://0.0.0.0:3300', 'webpack/hot/only-dev-server', path.join(__dirname, 'src/app/index.js')], main: './src/app/index.js'
lib: ['d3', 'react', 'react-dom', 'classnames', 'fbemitter', 'lz-string']
}, },
resolve: { resolve: {
// When requiring, you don't need to add these extensions // When requiring, you don't need to add these extensions
extensions: ['.js', '.jsx', '.json', '.less'] extensions: ['.js', '.jsx', '.json', '.less']
}, },
optimization: {
minimize: false,
splitChunks: {
chunks: 'all'
}
},
output: { output: {
path: path.join(__dirname, 'build'), path: path.join(__dirname, 'build'),
filename: 'app.js', filename: 'app.js',
publicPath: '/' publicPath: '/'
}, },
plugins: [ plugins: [
new CopyDirPlugin(path.join(__dirname, 'src/.htaccess'), ''), new CopyWebpackPlugin(['src/.htaccess']),
new webpack.optimize.CommonsChunkPlugin({ // new webpack.optimize.CommonsChunkPlugin({
name: 'lib', // name: 'lib',
filename: 'lib.js' // filename: 'lib.js'
}), // }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: false, inject: true,
template: path.join(__dirname, 'src/index.ejs'), template: path.join(__dirname, 'src/index.ejs'),
version: pkgJson.version, version: pkgJson.version,
date: buildDate, date: buildDate,

View File

@@ -1,63 +1,42 @@
const path = require('path'); const path = require('path');
const exec = require('child_process').exec;
const webpack = require('webpack'); const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
const { InjectManifest } = require('workbox-webpack-plugin'); const { InjectManifest } = require('workbox-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins'); const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins');
const pkgJson = require('./package'); const pkgJson = require('./package');
const buildDate = new Date(); const buildDate = new Date();
function CopyDirPlugin(source, destination) {
this.source = source;
this.destination = destination;
}
CopyDirPlugin.prototype.apply = function(compiler) {
compiler.plugin('done', () => {
console.log(compiler.outputPath, this.destination);
exec('cp -r ' + this.source + ' ' + path.join(compiler.outputPath, this.destination));
});
};
module.exports = { module.exports = {
cache: true,
devtool: 'source-map', devtool: 'source-map',
entry: { entry: {
app: ['babel-polyfill', path.resolve(__dirname, 'src/app/index')], main: ['babel-polyfill', './src/app/index.js']
lib: ['d3', 'react', 'react-dom', 'classnames', 'fbemitter', 'lz-string']
}, },
resolve: { resolve: {
extensions: ['.js', '.jsx', '.json', '.less'] extensions: ['.js', '.jsx', '.json', '.less']
}, },
output: { output: {
path: path.join(__dirname, 'build'), path: path.join(__dirname, 'build'),
filename: '[name].[chunkhash:6].js', filename: '[name].[hash].js',
chunkFilename: '[name].[chunkhash:6]', publicPath: '/',
publicPath: '/' globalObject: 'this'
},
mode: 'production',
optimization: {
minimize: false,
splitChunks: {
chunks: 'all'
}
}, },
plugins: [ plugins: [
new webpack.optimize.UglifyJsPlugin({ new CopyWebpackPlugin(['src/.htaccess', { from: 'src/schemas', to: 'schemas' }, 'src/images/logo/*']),
'screw-ie8': true,
sourceMap: true
}),
// new webpack.optimize.CommonsChunkPlugin({ // new webpack.optimize.CommonsChunkPlugin({
// name: 'lib', // name: 'lib',
// filename: 'lib.[chunkhash:6].js' // filename: 'lib.[chunkhash:6].js'
// }), // }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: false, inject: true,
appCache: 'coriolis.appcache',
minify: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
},
template: path.join(__dirname, 'src/index.ejs'), template: path.join(__dirname, 'src/index.ejs'),
uaTracking: process.env.CORIOLIS_UA_TRACKING || '', uaTracking: process.env.CORIOLIS_UA_TRACKING || '',
gapiKey: process.env.CORIOLIS_GAPI_KEY || '', gapiKey: process.env.CORIOLIS_GAPI_KEY || '',
@@ -65,17 +44,14 @@ module.exports = {
version: pkgJson.version version: pkgJson.version
}), }),
new ExtractTextPlugin({ new ExtractTextPlugin({
filename: '[contenthash:6].css', filename: '[hash:6].css',
disable: false, disable: false,
allChunks: true allChunks: true
}), }),
new BugsnagSourceMapUploaderPlugin({ // new BugsnagSourceMapUploaderPlugin({
apiKey: 'ba9fae819372850fb660755341fa6ef5', // apiKey: 'ba9fae819372850fb660755341fa6ef5',
appVersion: `${pkgJson.version}-${buildDate.toISOString()}` // appVersion: `${pkgJson.version}-${buildDate.toISOString()}`
}), // }),
new CopyDirPlugin(path.join(__dirname, 'src/schemas'), 'schemas'),
new CopyDirPlugin(path.join(__dirname, 'src/images/logo/*'), ''),
new CopyDirPlugin(path.join(__dirname, 'src/.htaccess'), ''),
new InjectManifest({ new InjectManifest({
swSrc: './src/sw.js', swSrc: './src/sw.js',
importWorkboxFrom: 'cdn', importWorkboxFrom: 'cdn',