From 4a0acfc018d09454d5db2194b2c76fb3e2fad2d5 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 28 Nov 2023 06:07:31 +0100 Subject: [PATCH] [MIRROR] Improves tgui build speed [MDB IGNORE] (#25290) * Improves tgui build speed (#79916) ## About The Pull Request Swaps out our minimizer, Terser, with esbuildplugin. This is the engine behind vite. This is a pretty straight forward replacement, let's let the numbers do the talking:
Test environment / My specs intel i7-13700kf 32GB RAM windows 11 intel 660p m.2 SSD asus 4080 TUF series
Fresh build Test steps: 1. Delete `tgui/.yarn/webpack` folder 2. `CTRL SHIFT B` Results: ![fresh](https://github.com/tgstation/tgstation/assets/42397676/f337366f-2260-41b7-9ad6-f81f6f78e9e7) terser averages `25.16s` esbuild averages `19.37s` - 23% faster
Cached build (assuming files are already there, CTRL SHIFT B if not) 1. add a comment to an interface file 2. `CTRL SHIFT B` Results: ![cached](https://github.com/tgstation/tgstation/assets/42397676/89dc1c4b-a5b4-436d-a7e2-86683b6168f4) terser averages `9s` esbuild averages `3.52s` - 60.91% faster
## Why It's Good For The Game Faster dev environment ## Changelog N/A nothing player facing * Improves tgui build speed --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> --- tgui/package.json | 2 +- tgui/webpack.config.js | 14 +- tgui/yarn.lock | 293 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 296 insertions(+), 13 deletions(-) diff --git a/tgui/package.json b/tgui/package.json index c42971992b5..32e24fcff40 100644 --- a/tgui/package.json +++ b/tgui/package.json @@ -38,6 +38,7 @@ "babel-plugin-transform-remove-console": "^6.9.4", "common": "workspace:*", "css-loader": "^6.8.1", + "esbuild-loader": "^4.0.2", "eslint": "^7.32.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-radar": "^0.2.1", @@ -53,7 +54,6 @@ "sass": "^1.69.5", "sass-loader": "^13.3.2", "style-loader": "^3.3.3", - "terser-webpack-plugin": "^5.3.9", "typescript": "^4.9.4", "url-loader": "^4.1.1", "webpack": "^5.89.0", diff --git a/tgui/webpack.config.js b/tgui/webpack.config.js index 1bc9f209cbd..3438dd9c5c9 100644 --- a/tgui/webpack.config.js +++ b/tgui/webpack.config.js @@ -135,17 +135,11 @@ module.exports = (env = {}, argv) => { // Production build specific options if (mode === 'production') { - const TerserPlugin = require('terser-webpack-plugin'); + const { EsbuildPlugin } = require('esbuild-loader'); config.optimization.minimizer = [ - new TerserPlugin({ - extractComments: false, - terserOptions: { - ie8: true, - output: { - ascii_only: true, - comments: false, - }, - }, + new EsbuildPlugin({ + target: 'ie8', + css: true, }), ]; } diff --git a/tgui/yarn.lock b/tgui/yarn.lock index a29c27b0c21..b585be5ae35 100644 --- a/tgui/yarn.lock +++ b/tgui/yarn.lock @@ -1584,6 +1584,160 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-arm64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/android-arm64@npm:0.19.7" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/android-arm@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/android-arm@npm:0.19.7" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@esbuild/android-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/android-x64@npm:0.19.7" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/darwin-arm64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/darwin-arm64@npm:0.19.7" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/darwin-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/darwin-x64@npm:0.19.7" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/freebsd-arm64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/freebsd-arm64@npm:0.19.7" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/freebsd-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/freebsd-x64@npm:0.19.7" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/linux-arm64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-arm64@npm:0.19.7" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/linux-arm@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-arm@npm:0.19.7" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@esbuild/linux-ia32@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-ia32@npm:0.19.7" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/linux-loong64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-loong64@npm:0.19.7" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@esbuild/linux-mips64el@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-mips64el@npm:0.19.7" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@esbuild/linux-ppc64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-ppc64@npm:0.19.7" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/linux-riscv64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-riscv64@npm:0.19.7" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@esbuild/linux-s390x@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-s390x@npm:0.19.7" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@esbuild/linux-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/linux-x64@npm:0.19.7" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/netbsd-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/netbsd-x64@npm:0.19.7" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/openbsd-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/openbsd-x64@npm:0.19.7" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/sunos-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/sunos-x64@npm:0.19.7" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/win32-arm64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/win32-arm64@npm:0.19.7" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/win32-ia32@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/win32-ia32@npm:0.19.7" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/win32-x64@npm:0.19.7": + version: 0.19.7 + resolution: "@esbuild/win32-x64@npm:0.19.7" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@eslint/eslintrc@npm:^0.4.3": version: 0.4.3 resolution: "@eslint/eslintrc@npm:0.4.3" @@ -4923,6 +5077,97 @@ __metadata: languageName: node linkType: hard +"esbuild-loader@npm:^4.0.2": + version: 4.0.2 + resolution: "esbuild-loader@npm:4.0.2" + dependencies: + esbuild: ^0.19.0 + get-tsconfig: ^4.7.0 + loader-utils: ^2.0.4 + webpack-sources: ^1.4.3 + peerDependencies: + webpack: ^4.40.0 || ^5.0.0 + checksum: beecdeb9fd1d88aceaedc3914bf35c239d7771f767b6afca68dbf4c58adde71ab0506704ed6c713329aa5cf0241c1ff6d4834562571b88bb243a8245710933ae + languageName: node + linkType: hard + +"esbuild@npm:^0.19.0": + version: 0.19.7 + resolution: "esbuild@npm:0.19.7" + dependencies: + "@esbuild/android-arm": 0.19.7 + "@esbuild/android-arm64": 0.19.7 + "@esbuild/android-x64": 0.19.7 + "@esbuild/darwin-arm64": 0.19.7 + "@esbuild/darwin-x64": 0.19.7 + "@esbuild/freebsd-arm64": 0.19.7 + "@esbuild/freebsd-x64": 0.19.7 + "@esbuild/linux-arm": 0.19.7 + "@esbuild/linux-arm64": 0.19.7 + "@esbuild/linux-ia32": 0.19.7 + "@esbuild/linux-loong64": 0.19.7 + "@esbuild/linux-mips64el": 0.19.7 + "@esbuild/linux-ppc64": 0.19.7 + "@esbuild/linux-riscv64": 0.19.7 + "@esbuild/linux-s390x": 0.19.7 + "@esbuild/linux-x64": 0.19.7 + "@esbuild/netbsd-x64": 0.19.7 + "@esbuild/openbsd-x64": 0.19.7 + "@esbuild/sunos-x64": 0.19.7 + "@esbuild/win32-arm64": 0.19.7 + "@esbuild/win32-ia32": 0.19.7 + "@esbuild/win32-x64": 0.19.7 + dependenciesMeta: + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: a5d979224d47ae0cc6685447eb8f1ceaf7b67f5eaeaac0246f4d589ff7d81b08e4502a6245298d948f13e9b571ac8556a6d83b084af24954f762b1cfe59dbe55 + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -5801,6 +6046,15 @@ __metadata: languageName: node linkType: hard +"get-tsconfig@npm:^4.7.0": + version: 4.7.2 + resolution: "get-tsconfig@npm:4.7.2" + dependencies: + resolve-pkg-maps: ^1.0.0 + checksum: 172358903250eff0103943f816e8a4e51d29b8e5449058bdf7266714a908a48239f6884308bd3a6ff28b09f692b9533dbebfd183ab63e4e14f073cda91f1bca9 + languageName: node + linkType: hard + "getpass@npm:^0.1.1": version: 0.1.7 resolution: "getpass@npm:0.1.7" @@ -7793,6 +8047,17 @@ __metadata: languageName: node linkType: hard +"loader-utils@npm:^2.0.4": + version: 2.0.4 + resolution: "loader-utils@npm:2.0.4" + dependencies: + big.js: ^5.2.2 + emojis-list: ^3.0.0 + json5: ^2.1.2 + checksum: a5281f5fff1eaa310ad5e1164095689443630f3411e927f95031ab4fb83b4a98f388185bb1fe949e8ab8d4247004336a625e9255c22122b815bb9a4c5d8fc3b7 + languageName: node + linkType: hard + "locate-path@npm:^5.0.0": version: 5.0.0 resolution: "locate-path@npm:5.0.0" @@ -9519,6 +9784,13 @@ __metadata: languageName: node linkType: hard +"resolve-pkg-maps@npm:^1.0.0": + version: 1.0.0 + resolution: "resolve-pkg-maps@npm:1.0.0" + checksum: 1012afc566b3fdb190a6309cc37ef3b2dcc35dff5fa6683a9d00cd25c3247edfbc4691b91078c97adc82a29b77a2660c30d791d65dab4fc78bfc473f60289977 + languageName: node + linkType: hard + "resolve.exports@npm:^2.0.0": version: 2.0.2 resolution: "resolve.exports@npm:2.0.2" @@ -10094,6 +10366,13 @@ __metadata: languageName: node linkType: hard +"source-list-map@npm:^2.0.0": + version: 2.0.1 + resolution: "source-list-map@npm:2.0.1" + checksum: 806efc6f75e7cd31e4815e7a3aaf75a45c704871ea4075cb2eb49882c6fca28998f44fc5ac91adb6de03b2882ee6fb02f951fdc85e6a22b338c32bfe19557938 + languageName: node + linkType: hard + "source-map-js@npm:>=0.6.2 <2.0.0, source-map-js@npm:^1.0.2": version: 1.0.2 resolution: "source-map-js@npm:1.0.2" @@ -10615,7 +10894,7 @@ __metadata: languageName: node linkType: hard -"terser-webpack-plugin@npm:^5.3.7, terser-webpack-plugin@npm:^5.3.9": +"terser-webpack-plugin@npm:^5.3.7": version: 5.3.9 resolution: "terser-webpack-plugin@npm:5.3.9" dependencies: @@ -10775,6 +11054,7 @@ __metadata: babel-plugin-transform-remove-console: ^6.9.4 common: "workspace:*" css-loader: ^6.8.1 + esbuild-loader: ^4.0.2 eslint: ^7.32.0 eslint-config-prettier: ^9.0.0 eslint-plugin-radar: ^0.2.1 @@ -10790,7 +11070,6 @@ __metadata: sass: ^1.69.5 sass-loader: ^13.3.2 style-loader: ^3.3.3 - terser-webpack-plugin: ^5.3.9 typescript: ^4.9.4 url-loader: ^4.1.1 webpack: ^5.89.0 @@ -11603,6 +11882,16 @@ __metadata: languageName: node linkType: hard +"webpack-sources@npm:^1.4.3": + version: 1.4.3 + resolution: "webpack-sources@npm:1.4.3" + dependencies: + source-list-map: ^2.0.0 + source-map: ~0.6.1 + checksum: 37463dad8d08114930f4bc4882a9602941f07c9f0efa9b6bc78738cd936275b990a596d801ef450d022bb005b109b9f451dd087db2f3c9baf53e8e22cf388f79 + languageName: node + linkType: hard + "webpack-sources@npm:^3.2.3": version: 3.2.3 resolution: "webpack-sources@npm:3.2.3"