Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sourcemaps from add-on? #12

Open
pdehaan opened this issue Oct 1, 2020 · 4 comments
Open

Remove sourcemaps from add-on? #12

pdehaan opened this issue Oct 1, 2020 · 4 comments

Comments

@pdehaan
Copy link

pdehaan commented Oct 1, 2020

I downloaded and extracted the XPI and it looks like the directory is ~12MB (per du -sh).

I did a bit of digging and it looks like we have around 7.2MB of *.map files, and around 1.3MB of *.woff* files.

node file-lint.js

.map    => 7,234.466 KB
.woff   => 714.438 KB
.woff2  => 578.016 KB
const fs = require("fs");
const glob = require("globby");

main([".map", ".woff", ".woff2"]);

async function main(exts=[]) {
  for (const ext of exts) {
    const files = await glob(`*${ext}`);
    const extSize = files.reduce((acc, file) => acc += fs.statSync(file).size, 0);
    console.log(`${ext}\t=> ${Number(extSize / 1024).toLocaleString()} KB`);
  }
}
@pdehaan
Copy link
Author

pdehaan commented Oct 3, 2020

Actually, I revised my script to scan all files in the signed XPI at any depth and try and summarize by file extension:

EXT FILES SIZE
.html 5 1 KB
.jpg 8 794 KB
.js 9 2,390 KB
.json 5 9 KB
.map 8 7,234 KB
.png 7 31 KB
.svg 3 8 KB
.woff 31 714 KB
.woff2 31 578 KB

@motin
Copy link
Contributor

motin commented Oct 12, 2020

Thanks @pdehaan. This is very useful. Personally I like the idea of having sourcemaps included in the bundle since it makes it more transparent how the executable code links up with the package js bundles, but this can also be verified by users/developers by rebuilding the sourcemaps from source, and having a smaller add-on bundle is of course positive. The difference in compressed package size between package with and without sourcemaps would be an important factor.

@pdehaan
Copy link
Author

pdehaan commented Oct 12, 2020

OK, I think I deleted files and re-saved the XPI correctly:

# ls -l regre*.xpi
-rw-r--r--  1 pdehaan  staff  2794327 12 Oct 08:23 regretsreporter-1.0.1-fx (1) copy.xpi
-rw-r--r--@ 1 pdehaan  staff  4663671 12 Oct 08:21 regretsreporter-1.0.1-fx (1).xpi

Or, with prettier file sizes...

# ls -lh regre*.xpi
5464 -rw-r--r--    1 pdehaan  staff   2.7M 12 Oct 08:23 regretsreporter-1.0.1-fx (1) copy.xpi
9112 -rw-r--r--@   1 pdehaan  staff   4.4M 12 Oct 08:21 regretsreporter-1.0.1-fx (1).xpi

Looks like the XPI from https://addons.mozilla.org/firefox/addon/regretsreporter/ is ~4.4MB, but if I edit the archive, delete the .map files and resave, it drops to ~2.7MB (roughly 1.7MB difference -- or 38.63% of the current XPI filesize is sourcemaps).

@motin
Copy link
Contributor

motin commented Oct 13, 2020

This is very informative, thanks @pdehaan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants