From 29ebb2bf301676ce5f2d34681a31c4b29a18520e Mon Sep 17 00:00:00 2001 From: Salman Al Fariz Date: Wed, 4 Sep 2019 16:07:00 +0700 Subject: [PATCH] fix(treats): fix webpack production build error (#37) * fix(packages/treats): fix webpack server build --- CHANGELOG.md | 15 ++++++++++++++- .../app-with-workbox/generate-sw/package.json | 4 ++-- .../inject-manifest/package.json | 4 ++-- .../my-first-addons/package.json | 4 ++-- .../authoring-addons/my-treats-app/package.json | 4 ++-- example/emotion-critical-css/package.json | 4 ++-- example/emotion-css/package.json | 4 ++-- example/less-css/package.json | 4 ++-- example/sass-css/package.json | 4 ++-- example/styled-components/package.json | 4 ++-- example/tutorial-app/package.json | 6 +++--- example/typescript-app/package.json | 4 ++-- lerna.json | 2 +- package.json | 2 +- .../generator/opinionated/package.json | 4 ++-- packages/addons-base/package.json | 4 ++-- .../create-treats-app/<%APP_NAME%>/package.json | 2 +- packages/create-treats-app/package.json | 2 +- packages/treats/package.json | 5 +++-- .../config/webpack.config.server.build.js | 16 ++++++++-------- .../config/webpack.config.server.development.js | 17 +++++++++-------- 21 files changed, 65 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 920600b..d0cac39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,23 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +# 0.4.3 (2019-09-03) + + +### Bug Fixes + +* Fix webpack production build with react-router-dom version 5.0.0. ([#37](https://github.com/tokopedia/treats/pull/37)) ([26afba7](https://github.com/tokopedia/treats/commit/26afba7)) This fix the temporary solution from ([#36](https://github.com/tokopedia/treats/pull/36)). + + + +# 0.4.2 (2019-09-02) ### Bug Fixes -* fix react-router-dom error on production build. ([#36](https://github.com/tokopedia/treats/pull/35)) +* fix react-router-dom error on production build. ([#36](https://github.com/tokopedia/treats/pull/36)) @@ -19,6 +30,8 @@ All notable changes to this project will be documented in this file. See [standa * fix vulnerable dependencies ([#35](https://github.com/tokopedia/treats/issues/35)) ([3115568](https://github.com/tokopedia/treats/commit/3115568)) + + # 0.4.0 (2019-06-24) diff --git a/example/app-with-workbox/generate-sw/package.json b/example/app-with-workbox/generate-sw/package.json index 71927af..f4601e8 100644 --- a/example/app-with-workbox/generate-sw/package.json +++ b/example/app-with-workbox/generate-sw/package.json @@ -1,6 +1,6 @@ { "name": "app-with-workbox", - "version": "0.0.3", + "version": "0.0.4", "description": "My First Treats App", "license": "ISC", "scripts": { @@ -22,6 +22,6 @@ "test:coverage": "treats test --coverage" }, "dependencies": { - "treats": "0.4.2" + "treats": "0.4.3" } } diff --git a/example/app-with-workbox/inject-manifest/package.json b/example/app-with-workbox/inject-manifest/package.json index 71927af..f4601e8 100644 --- a/example/app-with-workbox/inject-manifest/package.json +++ b/example/app-with-workbox/inject-manifest/package.json @@ -1,6 +1,6 @@ { "name": "app-with-workbox", - "version": "0.0.3", + "version": "0.0.4", "description": "My First Treats App", "license": "ISC", "scripts": { @@ -22,6 +22,6 @@ "test:coverage": "treats test --coverage" }, "dependencies": { - "treats": "0.4.2" + "treats": "0.4.3" } } diff --git a/example/authoring-addons/my-first-addons/package.json b/example/authoring-addons/my-first-addons/package.json index 2c2c74e..3734dcf 100644 --- a/example/authoring-addons/my-first-addons/package.json +++ b/example/authoring-addons/my-first-addons/package.json @@ -1,7 +1,7 @@ { "name": "@treats/my-first-addons", "license": "Apache-2.0", - "version": "1.0.2", + "version": "1.0.3", "description": "", "main": "index.js", "scripts": { @@ -9,6 +9,6 @@ }, "author": "Tokopedia Engineering", "peerDependencies": { - "treats": "0.4.2" + "treats": "0.4.3" } } diff --git a/example/authoring-addons/my-treats-app/package.json b/example/authoring-addons/my-treats-app/package.json index 730c0cf..4ace89d 100644 --- a/example/authoring-addons/my-treats-app/package.json +++ b/example/authoring-addons/my-treats-app/package.json @@ -1,6 +1,6 @@ { "name": "my-treats-app", - "version": "0.4.2", + "version": "0.4.3", "description": "My First Treats App", "license": "ISC", "scripts": { @@ -20,6 +20,6 @@ }, "dependencies": { "@treats/my-first-addons": "^1.0.0", - "treats": "0.4.2" + "treats": "0.4.3" } } diff --git a/example/emotion-critical-css/package.json b/example/emotion-critical-css/package.json index ae61b3e..5e1e12f 100644 --- a/example/emotion-critical-css/package.json +++ b/example/emotion-critical-css/package.json @@ -1,6 +1,6 @@ { "name": "emotion-example", - "version": "0.4.2", + "version": "0.4.3", "description": "Emotion Critical CSS Example", "license": "ISC", "scripts": { @@ -22,7 +22,7 @@ "emotion": "9.2.12", "emotion-server": "9.2.12", "react-emotion": "9.2.12", - "treats": "0.4.2" + "treats": "0.4.3" }, "devDependencies": { "babel-plugin-emotion": "9.2.11" diff --git a/example/emotion-css/package.json b/example/emotion-css/package.json index 8ed6f20..868427c 100644 --- a/example/emotion-css/package.json +++ b/example/emotion-css/package.json @@ -1,6 +1,6 @@ { "name": "emotion-css", - "version": "0.4.2", + "version": "0.4.3", "description": "Emotion CSS Example", "license": "ISC", "scripts": { @@ -22,7 +22,7 @@ "emotion": "9.2.12", "emotion-server": "9.2.12", "react-emotion": "9.2.12", - "treats": "0.4.2" + "treats": "0.4.3" }, "devDependencies": { "babel-plugin-emotion": "9.2.11" diff --git a/example/less-css/package.json b/example/less-css/package.json index 28a40b9..f4ad82e 100644 --- a/example/less-css/package.json +++ b/example/less-css/package.json @@ -1,6 +1,6 @@ { "name": "less-css", - "version": "0.4.2", + "version": "0.4.3", "description": "Less CSS example", "license": "ISC", "scripts": { @@ -19,7 +19,7 @@ "documentation:flush": "treats documentation flush src/" }, "dependencies": { - "treats": "0.4.2", + "treats": "0.4.3", "less": "2.3.1" } } diff --git a/example/sass-css/package.json b/example/sass-css/package.json index 277027c..7b13e1b 100644 --- a/example/sass-css/package.json +++ b/example/sass-css/package.json @@ -1,6 +1,6 @@ { "name": "sass-css", - "version": "0.4.2", + "version": "0.4.3", "description": "Sass CSS example", "license": "ISC", "scripts": { @@ -19,7 +19,7 @@ "documentation:flush": "treats documentation flush src/" }, "dependencies": { - "treats": "0.4.2", + "treats": "0.4.3", "node-sass": "4.10.0" } } diff --git a/example/styled-components/package.json b/example/styled-components/package.json index ff07f6c..00d6586 100644 --- a/example/styled-components/package.json +++ b/example/styled-components/package.json @@ -1,6 +1,6 @@ { "name": "styled-components", - "version": "0.4.2", + "version": "0.4.3", "description": "Styled Components Example", "license": "ISC", "scripts": { @@ -20,7 +20,7 @@ }, "dependencies": { "styled-components": "4.1.1", - "treats": "0.4.2" + "treats": "0.4.3" }, "devDependencies": { "babel-plugin-styled-components": "1.8.0" diff --git a/example/tutorial-app/package.json b/example/tutorial-app/package.json index bbdf5ae..57a0573 100644 --- a/example/tutorial-app/package.json +++ b/example/tutorial-app/package.json @@ -22,8 +22,8 @@ "test:coverage": "treats test --coverage" }, "dependencies": { - "@treats/addons-base": "0.4.2", - "axios": "^0.18.0", - "treats": "0.4.2" + "@treats/addons-base": "0.4.3", + "axios": "^0.18.1", + "treats": "0.4.3" } } diff --git a/example/typescript-app/package.json b/example/typescript-app/package.json index b4b2d70..28a065b 100644 --- a/example/typescript-app/package.json +++ b/example/typescript-app/package.json @@ -1,6 +1,6 @@ { "name": "typescript-app", - "version": "0.4.2", + "version": "0.4.3", "description": "My First Treats App with Typescript Language!", "license": "ISC", "scripts": { @@ -22,7 +22,7 @@ "test:coverage": "treats test --coverage" }, "dependencies": { - "treats": "0.4.2", + "treats": "0.4.3", "typescript": "3.2.2", "@types/enzyme": "3.1.15", "@types/jest": "23.3.10", diff --git a/lerna.json b/lerna.json index 4b56a35..09f9a45 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "2.11.0", - "version": "0.4.2", + "version": "0.4.3", "packages": [ "packages/*" ] diff --git a/package.json b/package.json index 5bba4dd..91d8c06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "treats-repo", - "version": "0.4.2", + "version": "0.4.3", "description": "Tokopedia React Development Kits Repository", "author": "Tokopedia Engineering", "license": "Apache-2.0", diff --git a/packages/addons-base/generator/opinionated/package.json b/packages/addons-base/generator/opinionated/package.json index 9dc42a1..ebd323e 100644 --- a/packages/addons-base/generator/opinionated/package.json +++ b/packages/addons-base/generator/opinionated/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "eslint": "5.8.0", - "eslint-config-treats": "0.1.1", + "eslint-config-treats": "0.4.0", "flow-bin": "0.67.1", "flow-coverage-report": "0.5.0", "flow-typed": "2.5.1", @@ -18,6 +18,6 @@ "lint-staged": "7.1.3", "prettier": "1.13.4", "stylelint": "9.7.1", - "stylelint-config-treats": "0.1.1" + "stylelint-config-treats": "0.4.0" } } diff --git a/packages/addons-base/package.json b/packages/addons-base/package.json index eeb3766..a2025a5 100644 --- a/packages/addons-base/package.json +++ b/packages/addons-base/package.json @@ -1,12 +1,12 @@ { "name": "@treats/addons-base", "license": "Apache-2.0", - "version": "0.4.2", + "version": "0.4.3", "description": "Treats Addons Base", "main": "index.js", "author": "Tokopedia Engineering", "peerDependencies": { - "treats": "0.4.2" + "treats": "0.4.3" }, "dependencies": { "bluebird": "3.5.1", diff --git a/packages/create-treats-app/generator/create-treats-app/<%APP_NAME%>/package.json b/packages/create-treats-app/generator/create-treats-app/<%APP_NAME%>/package.json index 9d80b9d..f2fa1d0 100644 --- a/packages/create-treats-app/generator/create-treats-app/<%APP_NAME%>/package.json +++ b/packages/create-treats-app/generator/create-treats-app/<%APP_NAME%>/package.json @@ -22,7 +22,7 @@ "test:coverage": "treats test --coverage" }, "dependencies": { - "treats": "0.4.1<%if(USE_TYPESCRIPT)%>", + "treats": "0.4.3<%if(USE_TYPESCRIPT)%>", "typescript": "3.2.2", "@types/enzyme": "3.1.15", "@types/jest": "23.3.10", diff --git a/packages/create-treats-app/package.json b/packages/create-treats-app/package.json index a8e893a..eb818f5 100644 --- a/packages/create-treats-app/package.json +++ b/packages/create-treats-app/package.json @@ -1,7 +1,7 @@ { "name": "create-treats-app", "license": "Apache-2.0", - "version": "0.4.2", + "version": "0.4.3", "description": "Create Treats App", "main": "./index.js", "bin": { diff --git a/packages/treats/package.json b/packages/treats/package.json index b285b2e..8c5cda0 100644 --- a/packages/treats/package.json +++ b/packages/treats/package.json @@ -1,7 +1,7 @@ { "name": "treats", "license": "Apache-2.0", - "version": "0.4.2", + "version": "0.4.3", "description": "Tokopedia React Development Kits", "author": "Tokopedia Engineering", "types": "./lib/treats.d.ts", @@ -110,7 +110,7 @@ "react-hot-loader": "4.6.0", "react-intl": "2.7.2", "react-redux": "5.1.0", - "react-router-dom": "4.3.1", + "react-router-dom": "5.0.0", "react-universal-component": "3.0.3", "redux": "4.0.1", "redux-devtools-extension": "2.13.5", @@ -127,6 +127,7 @@ "webpack-dev-server": "3.1.11", "webpack-flush-chunks": "1.2.3", "webpack-merge": "4.1.4", + "webpack-node-externals": "1.7.2", "webpack-source-map-support": "2.0.1", "winston": "2.4.2", "workbox-webpack-plugin": "4.1.0", diff --git a/packages/treats/scripts/config/webpack.config.server.build.js b/packages/treats/scripts/config/webpack.config.server.build.js index 20fd1d1..24cef32 100644 --- a/packages/treats/scripts/config/webpack.config.server.build.js +++ b/packages/treats/scripts/config/webpack.config.server.build.js @@ -9,7 +9,8 @@ const webpack = require("webpack"), babelMerge = require("babel-merge"), webpackMerge = require("webpack-merge"), extractEnv = require("./util/extract-env"), - useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json")); + useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json")), + nodeExternals = require("webpack-node-externals"); module.exports = ({ alias, @@ -40,13 +41,12 @@ module.exports = ({ ...resolve, alias }, - externals: fs - .readdirSync("./node_modules") - .filter(x => !/\.bin|react-universal-component|webpack-flush-chunks|treats/.test(x)) - .reduce((externals, mod) => { - externals[mod] = `commonjs ${mod}`; - return externals; - }, {}), + externals: nodeExternals({ + whitelist: [ + /\.bin|react-universal-component|webpack-flush-chunks|treats/, + /babel-plugin-universal-import|react-universal-component/ + ] + }), node: { __dirname: false }, diff --git a/packages/treats/scripts/config/webpack.config.server.development.js b/packages/treats/scripts/config/webpack.config.server.development.js index 6a923e8..1f2db27 100644 --- a/packages/treats/scripts/config/webpack.config.server.development.js +++ b/packages/treats/scripts/config/webpack.config.server.development.js @@ -8,7 +8,8 @@ const webpack = require("webpack"), babelMerge = require("babel-merge"), webpackMerge = require("webpack-merge"), extractEnv = require("./util/extract-env"), - useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json")); + useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json")), + nodeExternals = require("webpack-node-externals"); module.exports = ({ alias, @@ -33,13 +34,13 @@ module.exports = ({ mode: "development", devtool: "cheap-eval-source-map", entry: ["webpack/hot/signal?1000", path.join(alias["@treats/server"], "./entry")], - externals: fs - .readdirSync("./node_modules") - .filter(x => !/\.bin|react-universal-component|webpack-flush-chunks|treats/.test(x)) - .reduce((externals, mod) => { - externals[mod] = `commonjs ${mod}`; - return externals; - }, {}), + externals: nodeExternals({ + whitelist: [ + /\.bin|react-universal-component|webpack-flush-chunks|treats/, + /babel-plugin-universal-import|react-universal-component/, + "webpack/hot/signal?1000" + ] + }), watch: true, resolve: { ...resolve,