From 3db38fbd0b84d066d64f9b637f1efcc35ebf8ce3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 8 May 2019 01:32:33 +0200 Subject: [PATCH] restore webpack splitting behavior --- package.json | 1 + src/checkable.ts | 4 ++-- webpack.config.js | 26 ++++++++++++++++++++++---- yarn.lock | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a12f655f5..90f4ec580 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "react": "^16.8.5", "react-dom": "^16.8.5", "structured-clone": "^0.2.2", + "terser-webpack-plugin": "^1.2.3", "through2": "2.0.1", "tslint": "^5.14.0", "typedoc": "^0.14.2", diff --git a/src/checkable.ts b/src/checkable.ts index 52eb54120..2255209f1 100644 --- a/src/checkable.ts +++ b/src/checkable.ts @@ -150,7 +150,7 @@ export namespace Checkable { function checkMap(target: any, prop: Prop, path: Path): any { if (typeof target !== "object") { - throw new SchemaError(`expected object for ${path}, got ${typeof target} instead`); + throw new SchemaError(`expected object for ${path}, got ${typeof target} instead`); } for (const key in target) { prop.keyProp.checker(key, prop.keyProp, path.concat([key])); @@ -195,7 +195,7 @@ export namespace Checkable { if (innerProp.optional) { continue; } - throw new SchemaError(`Property ${innerProp.propertyKey} missing on ${path} of ${typeName}`); + throw new SchemaError(`Property '${innerProp.propertyKey}' missing on '${path}' of '${typeName}'`); } if (!remainingPropNames.delete(innerProp.propertyKey)) { throw new SchemaError("assertion failed"); diff --git a/webpack.config.js b/webpack.config.js index f0c2a16ce..68e8b3cac 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ const path = require('path'); const webpack = require('webpack'); const merge = require('webpack-merge'); const { CheckerPlugin } = require('awesome-typescript-loader') +const TerserPlugin = require('terser-webpack-plugin'); function externalsCb(context, request, callback) { @@ -17,7 +18,7 @@ module.exports = function (env) { const base = { output: { filename: '[name]-bundle.js', - chunkFilename: "[id].chunk.js", + chunkFilename: "[id]-bundle.js", path: path.resolve(__dirname, "dist"), }, module: { @@ -43,6 +44,18 @@ module.exports = function (env) { externalsCb, "child_process", ], + optimization: { + minimize: false, + minimizer: [ + new TerserPlugin({ + sourceMap: true, + terserOptions: { + keep_classnames: true, + keep_fnames: true, + } + }), + ], + } } const configWebWorker = { entry: {"cryptoWorker": "./src/crypto/cryptoWorker.ts"}, @@ -81,9 +94,14 @@ module.exports = function (env) { name: "pages", optimization: { splitChunks: { - name: "page-common", - minChunks: 2, - } + cacheGroups: { + commons: { + name: 'page-common', + chunks: 'all', + minChunks: 2, + }, + }, + }, }, }; diff --git a/yarn.lock b/yarn.lock index 573ec33ea..f624383b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6086,7 +6086,7 @@ term-size@^1.2.0: dependencies: execa "^0.7.0" -terser-webpack-plugin@^1.1.0: +terser-webpack-plugin@^1.1.0, terser-webpack-plugin@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.2.3.tgz#3f98bc902fac3e5d0de730869f50668561262ec8" integrity sha512-GOK7q85oAb/5kE12fMuLdn2btOS9OBZn4VsecpHDywoUC/jLhSAKOiYo0ezx7ss2EXPMzyEWFoE0s1WLE+4+oA==