1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 16:21:51 +00:00

Update webpack and simplify config

Update some webpack dependencies and remove unused ones. Replace
worker-loader with built-in worker loading functionality and remove
default/implied options from the webpack configuration files.
This commit is contained in:
Даниїл Григор'єв 2025-07-01 18:04:38 +03:00
parent ca5dd9b3e5
commit ba2e74b993
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D
6 changed files with 393 additions and 398 deletions

View File

@ -53,18 +53,6 @@ const moduleRules = [
fullySpecified: false,
},
},
{
test: /\.worker\.[jt]s$/,
use: [
{
loader: "worker-loader",
options: {
filename: "[fullhash].worker.js",
inline: "fallback",
},
},
],
},
];
/** @type {import("webpack").Configuration} */
@ -98,7 +86,4 @@ export default {
}),
],
module: { rules: moduleRules },
experiments: {
topLevelAwait: true,
},
};

View File

@ -62,18 +62,6 @@ const moduleRules = [
fullySpecified: false,
},
},
{
test: /\.worker\.[jt]s$/,
use: [
{
loader: "worker-loader",
options: {
filename: "[fullhash].worker.js",
inline: "fallback",
},
},
],
},
];
/** @type {import("webpack").Configuration} */
@ -94,35 +82,19 @@ export default {
extensions: [".ts", ".js", ".tsx", ".jsx"],
},
stats: { optimizationBailout: true },
devtool: false,
optimization: {
noEmitOnErrors: true,
removeAvailableModules: true,
removeEmptyChunks: true,
mergeDuplicateChunks: true,
flagIncludedChunks: true,
providedExports: true,
usedExports: true,
concatenateModules: true,
sideEffects: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 2020,
parse: {},
module: true,
toplevel: true,
keep_classnames: true,
keep_fnames: true,
compress: {
arguments: false,
drop_console: false,
global_defs: globalDefs,
keep_fargs: true,
keep_infinity: true,
passes: 2,
module: true,
pure_funcs: [
"Math.radians",
"Math.degrees",
@ -141,23 +113,11 @@ export default {
"Math.pow",
"Math.atan2",
],
toplevel: true,
unsafe_math: true,
unsafe_arrows: false,
},
mangle: {
eval: true,
keep_classnames: true,
keep_fnames: true,
module: true,
toplevel: true,
},
output: {
format: {
comments: false,
ascii_only: true,
beautify: false,
braces: false,
ecma: 2020,
},
},
}),
@ -176,7 +136,4 @@ export default {
maxEntrypointSize: 5120000,
maxAssetSize: 5120000,
},
experiments: {
topLevelAwait: true,
},
};

713
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,6 @@
"@types/gulp": "^4.0.9",
"@types/gulp-htmlmin": "^1.3.32",
"@types/node": "^22.14.0",
"@types/webpack": "^5.28.0",
"browser-sync": "^2.27.10",
"circular-dependency-plugin": "^5.2.2",
"css-mqpacker": "^7.0.0",
@ -71,15 +70,14 @@
"postcss-preset-env": "^6.5.0",
"postcss-round-subpixels": "^1.2.0",
"prettier": "^3.3.2",
"terser-webpack-plugin": "^5.3.6",
"ts-loader": "^9.4.2",
"terser-webpack-plugin": "^5.3.14",
"ts-loader": "^9.5.2",
"typescript": "^5.8.2",
"typescript-eslint": "^8.29.1",
"webpack": "^5.75.0",
"webpack": "^5.99.9",
"webpack-deadcode-plugin": "^0.1.17",
"webpack-stream": "^7.0.0",
"webpack-strip-block": "^0.2.0",
"worker-loader": "^3.0.8",
"yaml": "^1.10.0"
}
}

View File

@ -1,8 +1,5 @@
import { Signal } from "./signal";
// @ts-ignore
import BackgroundAnimationFrameEmitterWorker from "../webworkers/background_animation_frame_emittter.worker";
import { createLogger } from "./logging";
const logger = createLogger("animation_frame");
@ -21,7 +18,9 @@ export class AnimationFrame {
this.boundMethod = this.handleAnimationFrame.bind(this);
this.backgroundWorker = new BackgroundAnimationFrameEmitterWorker();
this.backgroundWorker = new Worker(
new URL("../webworkers/background_animation_frame_emittter", import.meta.url)
);
this.backgroundWorker.addEventListener("error", err => {
logger.error("Error in background fps worker:", err);
});

View File

@ -1,3 +1,5 @@
/// <reference lib="WebWorker" />
// We clamp high deltas so 30 fps is fairly ok
const bgFps = 30;
const desiredMsDelay = 1000 / bgFps;
@ -9,7 +11,6 @@ function tick() {
const delta = now - lastTick;
lastTick = now;
// @ts-ignore
self.postMessage({ delta });
}