1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 10:11:50 +00:00

Fix All Shapez Exports Being Const (#1358)

* Allowed setting of variables inside webpack modules

* remove console log

* Fix stringification of things inside of eval

Co-authored-by: Edward Badel <you@example.com>
This commit is contained in:
Bagel03 2022-02-01 08:05:58 -05:00 committed by GitHub
parent 7dbed9fc43
commit 321971dadd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

3
gulp/mod.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (source, map) {
return source + `\nexport let $s=(n,v)=>eval(n+"=v")`;
};

View File

@ -93,6 +93,9 @@ module.exports = ({ watch = false, standalone = false, chineseVersion = false, w
end: "typehints:end",
},
},
{
loader: path.resolve(__dirname, "mod.js"),
},
],
},
{

View File

@ -112,18 +112,20 @@ export class ModLoader {
// @ts-ignore
const module = modules(key);
for (const member in module) {
if (member === "default") {
if (member === "default" || member === "$s") {
// Setter
continue;
}
if (exports[member]) {
throw new Error("Duplicate export of " + member);
}
Object.defineProperty(exports, member, {
get() {
return module[member];
},
set(v) {
module[member] = v;
module["$s"](member, v);
},
});
}