moonlight-mod / moonlight

Yet another Discord mod
https://moonlight-mod.github.io
GNU Lesser General Public License v3.0
102 stars 6 forks source link

build: Use an IIFE where possible #88

Closed NotNite closed 1 month ago

NotNite commented 1 month ago

We weren't wrapping things in an IIFE so global scope was being ruined by various dependencies (e.g. window was full of minified variable names lol). This PR fixes this by wrapping everything in an IIFE and telling esbuild to assign it to global variable module.exports to fix the exports. This results in this very funny build output:

"use strict";
var module;
(module ||= {}).exports = (() => {
  // ...
})();

Should be ready to merge, I just want to test this heavily as it could break everything. This will also need to be brought over to the sample extension build script.

NotNite commented 1 month ago

Tested and it seems to be OK. If shit breaks it's my fault. :p