chore: update dependencies and bundler cleanup

This commit is contained in:
Percs 2024-10-11 12:39:06 -05:00
parent b9d60e96e2
commit 91031ff92f
3 changed files with 636 additions and 1194 deletions

View file

@ -9,7 +9,7 @@
"url": "https://github.com/MercuryWorkshop/scramjet" "url": "https://github.com/MercuryWorkshop/scramjet"
}, },
"scripts": { "scripts": {
"build": "rspack build", "build": "rspack build --mode production",
"rewriter:build": "cd rewriter && bash build.sh && cd ..", "rewriter:build": "cd rewriter && bash build.sh && cd ..",
"dev": "node server.js", "dev": "node server.js",
"prepublish": "pnpm build", "prepublish": "pnpm build",
@ -28,39 +28,35 @@
"devDependencies": { "devDependencies": {
"@fastify/static": "^8.0.1", "@fastify/static": "^8.0.1",
"@mercuryworkshop/bare-as-module3": "^2.2.2", "@mercuryworkshop/bare-as-module3": "^2.2.2",
"@mercuryworkshop/epoxy-transport": "^2.1.13", "@mercuryworkshop/epoxy-transport": "^2.1.15",
"@mercuryworkshop/libcurl-transport": "^1.3.10", "@mercuryworkshop/libcurl-transport": "^1.3.10",
"@rsdoctor/rspack-plugin": "^0.4.4", "@rsdoctor/rspack-plugin": "^0.4.6",
"@rspack/cli": "^1.0.5", "@rspack/cli": "^1.0.10",
"@rspack/core": "^1.0.5", "@rspack/core": "^1.0.10",
"@tomphttp/bare-server-node": "2.0.3", "@tomphttp/bare-server-node": "2.0.3",
"@types/eslint": "^8.56.10", "@types/eslint": "^8.56.10",
"@types/estree": "^1.0.5", "@types/estree": "^1.0.5",
"@types/node": "^20.14.10", "@types/node": "^20.14.10",
"@types/serviceworker": "^0.0.96", "@types/serviceworker": "^0.0.98",
"@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0", "@typescript-eslint/parser": "^6.21.0",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"fastify": "^5.0.0", "fastify": "^5.0.0",
"javascript-obfuscator": "^4.1.1",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"tslib": "^2.6.2", "tslib": "^2.7.0",
"typescript": "^5.6.2", "typescript": "^5.6.3",
"uglifyjs-webpack-plugin": "^2.2.0", "wisp-server-node": "^1.1.7"
"wisp-server-node": "^1.1.4"
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@mercuryworkshop/bare-mux": "^2.1.2", "@mercuryworkshop/bare-mux": "^2.1.2",
"@webreflection/idb-map": "^0.3.1", "@webreflection/idb-map": "^0.3.2",
"devtools-detector": "^2.0.22",
"dom-serializer": "^2.0.0", "dom-serializer": "^2.0.0",
"domhandler": "^5.0.3", "domhandler": "^5.0.3",
"domutils": "^3.1.0", "domutils": "^3.1.0",
"htmlparser2": "^9.1.0", "htmlparser2": "^9.1.0",
"parse-domain": "^8.2.2", "parse-domain": "^8.2.2",
"set-cookie-parser": "^2.7.0", "set-cookie-parser": "^2.7.0"
"webpack-obfuscator": "^3.5.1"
} }
} }

1761
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,6 @@
import { defineConfig } from "@rspack/cli"; import { defineConfig } from "@rspack/cli";
import { rspack } from "@rspack/core"; import { rspack } from "@rspack/core";
import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin"; import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
import obfuscator from "javascript-obfuscator";
const { obfuscate } = obfuscator;
import { readFile } from "node:fs/promises"; import { readFile } from "node:fs/promises";
import { join } from "path"; import { join } from "path";
@ -55,9 +53,6 @@ export default defineConfig({
}, },
}, },
}, },
optimization: {
minimize: process.env.OBFUSCATE === "true",
},
output: { output: {
filename: "scramjet.[name].js", filename: "scramjet.[name].js",
path: join(__dirname, "dist"), path: join(__dirname, "dist"),
@ -71,44 +66,6 @@ export default defineConfig({
new rspack.DefinePlugin({ new rspack.DefinePlugin({
VERSION: JSON.stringify(packagemeta.version), VERSION: JSON.stringify(packagemeta.version),
}), }),
process.env.OBFUSCATE === "true" && {
apply(compiler) {
compiler.hooks.compilation.tap("GyatPlugin", (compilation) => {
compilation.hooks.processAssets.tap(
{
name: "GyatPlugin",
stage: compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
},
(assets) => {
for (const asset in assets) {
// inject code
compilation.updateAsset(asset, (source) => {
return {
source: () => {
return obfuscate(source.source(), {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
numbersToExpressions: true,
simplify: true,
deadCodeInjection: true,
selfDefending: true,
renameGlobals: true,
transformObjectKeys: true,
stringArrayShuffle: true,
splitStrings: true,
stringArrayThreshold: 1,
domainLock: ["localhost", process.env.DOMAIN],
}).getObfuscatedCode();
},
};
});
}
}
);
});
},
},
process.env.DEBUG === "true" process.env.DEBUG === "true"
? new RsdoctorRspackPlugin({ ? new RsdoctorRspackPlugin({
supports: { supports: {