From 312f45a169f5f94e62d5327006b726f91175cb95 Mon Sep 17 00:00:00 2001 From: Ernest Francis Date: Sun, 3 Feb 2019 13:22:31 -0500 Subject: [PATCH] upgraded Babel/Webpack packages --- .babelrc | 2 +- .editorconfig | 9 ++++++ .eslintrc | 12 +++---- examples/todomvc/src/stores/ViewStore.js | 6 ++-- package.json | 27 ++++++++-------- webpack.config.base.js | 5 +-- webpack.config.development.js | 21 ++++++++----- webpack.config.production.js | 40 +++++++++++++++--------- 8 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 .editorconfig diff --git a/.babelrc b/.babelrc index 65836a6..2b7bafa 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["es2015-loose", "stage-0", "react"] + "presets": ["@babel/preset-env", "@babel/preset-react"] } diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b918765 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# settings for JavaScript files +[*.{js,jsx,ts,tsx,json,md,css}] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +trim_trailing_whitespace = true +insert_final_newline = true +quote_type = single \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index 6e8ed8a..55fe92a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,5 @@ { - "extends": "eslint-config-airbnb", + "extends": ["eslint-config-airbnb", "eslint-config-prettier"], "env": { "mocha": true, "browser": true, @@ -13,8 +13,8 @@ "react/jsx-quotes": 0, "block-scoped-var": 0, "padded-blocks": 0, - "quotes": [ 1, "single" ], - "comma-style": [ 2, "last" ], + "quotes": [1, "single"], + "comma-style": [2, "last"], "eol-last": 0, "no-unused-vars": 0, "no-console": 0, @@ -23,11 +23,9 @@ "prefer-arrow-callback": 0, "comma-dangle": 0, "id-length": 0, - "indent": [2, 2, {"SwitchCase": 1}], + "indent": [2, 2, { "SwitchCase": 1 }], "default-case": 0, "no-underscore-dangle": 0 }, - "plugins": [ - "react" - ] + "plugins": ["react"] } diff --git a/examples/todomvc/src/stores/ViewStore.js b/examples/todomvc/src/stores/ViewStore.js index 93b1736..2d543c2 100755 --- a/examples/todomvc/src/stores/ViewStore.js +++ b/examples/todomvc/src/stores/ViewStore.js @@ -1,10 +1,10 @@ -import {observable} from 'mobx'; +import { observable } from 'mobx'; import { ALL_TODOS } from '../constants'; import remotedev from 'mobx-remotedev/lib/dev'; class ViewStore { - @observable todoBeingEdited = null; - @observable todoFilter= ALL_TODOS; + @observable todoBeingEdited = null; + @observable todoFilter = ALL_TODOS; } export default remotedev(ViewStore, { name: 'ViewStore' }); diff --git a/package.json b/package.json index 819416f..fe7a2e2 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "dist" ], "scripts": { - "clean": "rimraf lib", + "clean": "rimraf lib dist", "build:lib": "babel src --out-dir lib", - "build:umd": "webpack src/index.js dist/mobx-remotedev.js --config webpack.config.development.js", - "build:umd:min": "webpack src/index.js dist/mobx-remotedev.min.js --config webpack.config.production.js", + "build:umd": "webpack --config webpack.config.development.js", + "build:umd:min": "webpack --config webpack.config.production.js", "build": "npm run build:lib && npm run build:umd && npm run build:umd:min", "lint": "eslint src test", "prepublish": "npm run lint && npm run clean && npm run build" @@ -37,17 +37,15 @@ }, "homepage": "https://github.com/zalmoxisus/mobx-remotedev", "devDependencies": { - "babel-cli": "^6.10.1", - "babel-core": "^6.10.4", - "babel-eslint": "^6.0.5", - "babel-loader": "^6.2.4", - "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-preset-es2015": "^6.9.0", - "babel-preset-es2015-loose": "^7.0.0", - "babel-preset-react": "^6.5.0", - "babel-preset-stage-0": "^6.5.0", + "@babel/cli": "^7.2.3", + "@babel/core": "^7.2.2", + "@babel/preset-env": "^7.3.1", + "@babel/preset-react": "^7.0.0", + "babel-eslint": "^10.0.1", + "babel-loader": "^8.0.5", "eslint": "^2.13.1", "eslint-config-airbnb": "^9.0.1", + "eslint-config-prettier": "^4.0.0", "eslint-plugin-import": "^1.9.2", "eslint-plugin-jsx-a11y": "^1.5.3", "eslint-plugin-react": "^5.2.2", @@ -55,7 +53,10 @@ "mobx": "^4.1.1", "mocha": "^2.5.3", "rimraf": "^2.5.2", - "webpack": "^1.13.1" + "terser-webpack-plugin": "^1.2.1", + "webpack": "^4.29.0", + "webpack-cli": "^3.2.1", + "webpack-merge": "^4.2.1" }, "peerDependencies": { "mobx": ">=4.0.0" diff --git a/webpack.config.base.js b/webpack.config.base.js index f8ad329..4efdf5a 100644 --- a/webpack.config.base.js +++ b/webpack.config.base.js @@ -5,15 +5,16 @@ module.exports = { mobx: 'mobx' }, module: { - loaders: [ + rules: [ { test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ } ] }, + entry: './src/index.js', output: { library: 'RemoteDev', libraryTarget: 'umd' }, resolve: { - extensions: ['', '.js'] + extensions: ['.js'] } }; diff --git a/webpack.config.development.js b/webpack.config.development.js index 628c358..5b2e389 100644 --- a/webpack.config.development.js +++ b/webpack.config.development.js @@ -2,13 +2,18 @@ var webpack = require('webpack'); var baseConfig = require('./webpack.config.base'); +var merge = require('webpack-merge'); -var config = Object.create(baseConfig); -config.plugins = [ - new webpack.optimize.OccurenceOrderPlugin(), - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify('development') - }) -]; +var devConfig = { + mode: 'development', + plugins: [ + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('development') + }) + ], + output: { + filename: 'mobx-remotedev.js' + } +}; -module.exports = config; \ No newline at end of file +module.exports = merge(baseConfig, devConfig); diff --git a/webpack.config.production.js b/webpack.config.production.js index 858ab3d..c996d01 100644 --- a/webpack.config.production.js +++ b/webpack.config.production.js @@ -2,19 +2,31 @@ var webpack = require('webpack'); var baseConfig = require('./webpack.config.base'); +const TerserPlugin = require('terser-webpack-plugin'); +var merge = require('webpack-merge'); -var config = Object.create(baseConfig); -config.plugins = [ - new webpack.optimize.OccurenceOrderPlugin(), - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify('development') - }), - new webpack.optimize.UglifyJsPlugin({ - compressor: { - screw_ie8: true, - warnings: false - } - }) -]; +var prodConfig = { + mode: 'development', + plugins: [ + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('development') + }) + ], + optimization: { + minimizer: [ + new TerserPlugin({ + // cache: true, + parallel: true, + terserOptions: { + // keep function names for Mobx Injection + keep_fnames: true + } + }) + ] + }, + output: { + filename: 'mobx-remotedev.min.js' + } +}; -module.exports = config; \ No newline at end of file +module.exports = merge(baseConfig, prodConfig);