Skip to content

Commit

Permalink
feat: use terser-webpack-plugin because uglifyjs-webpack-plugin doesn…
Browse files Browse the repository at this point in the history
…'t support ES6+ anymore
  • Loading branch information
develar committed Nov 4, 2018
1 parent 0a9afdb commit 377b0eb
Show file tree
Hide file tree
Showing 14 changed files with 2,458 additions and 2,226 deletions.
12 changes: 12 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

// bloody babel 7 requires to use ONLY babel.config.js and old convenient key in package.json or .babelrc ARE NOT SUPPORTED ANYMORE
module.exports = function (api) {
// bloody babel 7 requires this string to revalidate cache of config on env change
api.env()
return {
"presets": [
"babel-preset-ts-node6-bluebird",
],
}
}
15 changes: 3 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"scripts": {
"compile": "cross-env BABEL_WORKAROUND2=true ts-babel packages/electron-webpack test && yarn schema",
"compile": "cross-env ts-babel packages/electron-webpack test && yarn schema",
"lint": "tslint -c ./node_modules/electron-builder-tslint-config/tslint.json -p packages/electron-webpack --exclude '**/*.js'",
"release": "BABEL_ENV=production yarn compile && ./npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s",
"test": "yarn compile && yarn lint && jest",
Expand All @@ -15,7 +15,6 @@
"update-deps": "lerna exec -- npm-check-updates -a"
},
"devDependencies": {
"@develar/gitbook": "3.2.11",
"@types/electron-devtools-installer": "^2.2.0",
"@types/jest": "^23.3.1",
"@types/memory-fs": "^0.3.1",
Expand All @@ -28,10 +27,6 @@
"develar-typescript-json-schema": "^0.20.0",
"electron-builder-tslint-config": "^1.1.0",
"fs-extra-p": "^4.6.1",
"gitbook-plugin-analytics": "^0.2.1",
"gitbook-plugin-edit-link": "^2.0.2",
"gitbook-plugin-github": "^2.0.0",
"gitbook-plugin-github-buttons": "^3.0.0",
"http-server": "^0.11.1",
"jest-cli": "^23.5.0",
"jest-junit": "^5.1.0",
Expand All @@ -40,12 +35,8 @@
"ts-babel": "^6.0.2",
"tslint": "^5.11.0",
"typescript": "^3.0.3",
"webpack": "^4.17.1"
},
"babel": {
"presets": [
"babel-preset-ts-node6-bluebird"
]
"webpack": "^4.17.1",
"terser-webpack-plugin": "^1.1.0"
},
"workspaces": [
"packages/*"
Expand Down
8 changes: 4 additions & 4 deletions packages/electron-webpack-eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "electron-webpack-eslint",
"version": "3.0.0",
"version": "4.0.0",
"license": "MIT",
"author": "Greg Holguin <simulatedgreg@gmail.com>",
"files": [],
"repository": "electron-userland/electron-webpack",
"dependencies": {
"babel-eslint": "^9.0.0",
"eslint": "^5.4.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.0"
"eslint-loader": "^2.1.1"
}
}
8 changes: 4 additions & 4 deletions packages/electron-webpack-js/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "electron-webpack-js",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"files": [],
"repository": "electron-userland/electron-webpack",
"dependencies": {
"@babel/core": "^7.0.0",
"babel-loader": "^8.0.0",
"@babel/core": "^7.1.2",
"babel-loader": "^8.0.4",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"babel-plugin-component": "^1.1.1"
}
}
8 changes: 4 additions & 4 deletions packages/electron-webpack-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "electron-webpack-ts",
"version": "2.1.1",
"version": "3.0.0",
"license": "MIT",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"files": [],
"repository": "electron-userland/electron-webpack",
"dependencies": {
"fork-ts-checker-webpack-plugin": "^0.4.9",
"ts-loader": "^4.5.0"
"fork-ts-checker-webpack-plugin": "^0.4.14",
"ts-loader": "^5.3.0"
},
"peerDependencies": {
"typescript": "^3.0.0"
"typescript": "^3.1.0"
}
}
6 changes: 3 additions & 3 deletions packages/electron-webpack-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "electron-webpack-vue",
"version": "2.2.1",
"version": "2.2.2",
"license": "MIT",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"files": [],
"repository": "electron-userland/electron-webpack",
"dependencies": {
"vue-class-component": "^6.2.0",
"vue-class-component": "^6.3.2",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.4.1",
"vue-loader": "^15.4.2",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.5.17"
}
Expand Down
28 changes: 14 additions & 14 deletions packages/electron-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@
"dependencies": {
"@types/webpack-env": "^1.13.6",
"async-exit-hook": "^2.0.1",
"uglifyjs-webpack-plugin": "^1.3.0",
"bluebird-lst": "^1.0.5",
"terser-webpack-plugin": "^1.1.0",
"bluebird-lst": "^1.0.6",
"chalk": "^2.4.1",
"crocket": "^0.9.11",
"css-hot-loader": "^1.4.2",
"css-loader": "^1.0.0",
"debug": "^3.1.0",
"css-loader": "^1.0.1",
"debug": "^4.1.0",
"electron-devtools-installer": "^2.2.4",
"electron-webpack-js": "~2.2.0",
"mini-css-extract-plugin": "^0.4.2",
"electron-webpack-js": "~2.3.0",
"mini-css-extract-plugin": "^0.4.4",
"file-loader": "^2.0.0",
"fs-extra-p": "^4.6.1",
"fs-extra-p": "^7.0.0",
"html-loader": "^1.0.0-alpha.0",
"html-webpack-plugin": "^3.2.0",
"lazy-val": "^1.0.3",
"node-loader": "^0.6.0",
"read-config-file": "^3.1.2",
"semver": "^5.5.1",
"read-config-file": "^3.1.3",
"semver": "^5.6.0",
"source-map-support": "^0.5.9",
"style-loader": "^0.23.0",
"url-loader": "^1.1.1",
"webpack-dev-server": "^3.1.7",
"style-loader": "^0.23.1",
"url-loader": "^1.1.2",
"webpack-dev-server": "^3.1.10",
"webpack-merge": "^4.1.4",
"yargs": "^12.0.1",
"webpack-cli": "^3.1.0"
"yargs": "^12.0.2",
"webpack-cli": "^3.1.2"
},
"peerDependencies": {
"webpack": "^4.8.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-webpack/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class WebpackConfigurator {
}

// if electronVersion not specified, use latest
this._electronVersion = this.electronWebpackConfiguration.electronVersion || await this.electronVersionPromise.value || "1.8.2"
this._electronVersion = this.electronWebpackConfiguration.electronVersion || await this.electronVersionPromise.value || "3.0.7"
const target = (() => {
switch (this.type) {
case "renderer": return new RendererTarget()
Expand Down
11 changes: 3 additions & 8 deletions packages/electron-webpack/src/targets/BaseTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,11 @@ export class BaseTarget {

if (configurator.isProduction) {
if (configurator.env.minify !== false) {
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
plugins.push(new UglifyJsPlugin({
const TerserPlugin = require("terser-webpack-plugin")
optimization.minimizer = [new TerserPlugin({
parallel: true,
sourceMap: true,
uglifyOptions: {
compress: {
ecma: 7,
},
},
}))
})]
}
optimization.minimize = true
plugins.push(new LoaderOptionsPlugin({minimize: true}))
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-webpack/src/targets/RendererTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class RendererTarget extends BaseRendererTarget {
// not configurable for now, as in the electron-vue
const customTemplateFile = path.join(configurator.projectDir, "src/index.ejs")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const nodeModulePath = configurator.isProduction ? null : path.resolve(require.resolve('electron'), '..', '..')
const nodeModulePath = configurator.isProduction ? null : path.resolve(require.resolve("electron"), "..", "..")

configurator.plugins.push(new HtmlWebpackPlugin({
filename: "index.html",
Expand Down
4 changes: 2 additions & 2 deletions test/out/__snapshots__/loaderDetectionTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resolve 'nunjucks-loader' in '<project-dir>'
[<root-dir>/packages/electron-webpack/node_modules/nunjucks-loader]
[<root-dir>/packages/electron-webpack/node_modules/nunjucks-loader.js]
[<root-dir>/packages/electron-webpack/node_modules/nunjucks-loader.json]
@ ./src/main/index.js 1:0-20
@ ./src/main/index.js 3:0-21
@ multi ./src/main/index.js"
`;
Expand Down Expand Up @@ -76,6 +76,6 @@ resolve 'sass-loader' in '<project-dir>'
[<root-dir>/packages/electron-webpack/node_modules/sass-loader]
[<root-dir>/packages/electron-webpack/node_modules/sass-loader.js]
[<root-dir>/packages/electron-webpack/node_modules/sass-loader.json]
@ ./src/renderer/index.js 1:0-21
@ ./src/renderer/index.js 3:0-22
@ multi ./src/renderer/index.js"
`;
Loading

0 comments on commit 377b0eb

Please sign in to comment.