JS Sourcemaps in production?

Hi!

I was just browsing my Nextcloud instance the other day when I wondered why the apps folder is so big. I quick check brought up, that many apps (maybe all of them) ship JavaScript sourcemap (.js.map) files. For example the calendar app. As far as I know, sourcemaps are not required in production, but to debug the JavaScript.

I did a little searching and found out, that my Nextcloud instance contains about 1500 JS sourcemap files which add up to about 1GB in total. That is a lot of stuff to ship if it is only needed for development. And these numbers increase if you count in the Nextcloud backups.

I wanted to ask if this is intentional behavior and if there is anything I am missing?
Maybe I did not find the right switch to turn the feature off or something like that?

I wrote a small thread about it, where you can see some numbers and folder structure.

Thanks for reading :slight_smile:

There was an issue in 2023. I would be interested in @ChristophWurst opinion. I am not a developer.

On one of my Nextclouds JavaScript requires 83 MB of 87 MB for the app Calendar (95%). The js.map files in turn require about 60 MB of the 83 MB (72%). This means that js.map require about 69% of the total memory of Calendar. I don’t know whether this applies to all apps. Perhaps I have miscalculated.

My minimum Nextcloud needs about 600 MB. I don’t know how much of that is js.map. But I think that’s quite a lot. Unfortunately, memory is no longer being saved these days. People are simply buying larger systems. What a pity.

The browser doesn’t load those files unless needed for a stack trace. If anything, this will make our developer’s life a lot harder if we can no longer read error traces.

That is correct, but …

… it play a role in terms of download, installation, update, backup and restore e.g. on a Raspberry Pi with a weak internet connection, weak processor, weak hard drive or bad sd card. During the runtime, however, it is irrelevant for the Pi.

… conversely, you may also have to compare the memory consumption for the apps with the actual amount of data for user data, which is often in the GB or TB range for one Nextcloud, it is practically unnoticeable.

1 Like

The size of the files is far less of an inconvenience than the advantages we have to debug and help fixing issues for both customers and community.

If you don’t want these files, delete them. That’s fine.

Like Christoph said in the other thread, we’ll keep them, we have no plans to drop them. :slight_smile:

3 Likes

Unfortunately I deleted the original post here. I understand that this is the Developer view.

Do you have numbers how many Nextcloud instances there are world wide?

The .map files are only used if you debug with the browser inspector. In that case, queries are done from it to check wether there is a .map corresponding to the source file. The purpose is to have a ā€œreadableā€ script for debugging purpose.So you can consider this is only anoying for the disk space (not the memory).

after installing nextcloud, or in a daily cron, you can launch this command:

find yourpath/nextcloud -name ā€œ*.mapā€ -exec rm {} \;

4 Likes

I never talked about memory. It is the disk space that bothers me. Like I said: itā€˜s 1GB already and another GB for every backup I have.

Why do I have to set up a cron job for cleaning up a mess I did not make?

Stay respectful, @mgx!

Nobody created a mess. This is how our frontend stack and its tooling works.

I acknowledge that the additional storage requirement might seem like a waste to some people, but as we tried to explain, there is a reason for the files.

We prefer debuggability and maintenance over storage optimization in this case.

If 1GB of storage is an issue, you will likely not be able to do much with your Nextcloud.

For backup I can highly recommend a deduplicating solution. Have a look at borg, for example.

2 Likes

We cannot remove the source maps completely for the reasons described above. It’s not only for ā€œdebugging by developersā€ purposes but also for bug reports.

ā€œButton didn’t work, and there is an unexpected token on main.js:1:15436ā€ is pretty useless on a bug report.

However, there are many source maps kinds. Some have less size with fewer possibilities. It can be, e.g., ~60% smaller, losing some but not all debugging options.

We might discuss this possibility, weighing the limitations and the outcomes.

4 Likes

I did not mean to by rude. For that I am sorry.

I will look into the cronjob solution that has been provided.

I still think making the sourcemaps optional with a toggle would save so many people enormous amounts of disk space.

I have to ask, how do you imagine this to work technically?

1 Like

Well, I wouldn’t necessarily call it ā€œenormousā€ in 2025. :wink:

From a user and admin perspective I’d like to have a toggle that does the clean up whenever I install a new version. One that makes the tradeoff clear: smaller install size but harder to debug.
Re adding the map files in case of needed debug info is harder but maybe not impossible? I don’t know enough of update process and how integrity is maintained with plugins.

It is big if your server has 10GB in total and you have three backups laying around.

Your server only has 10GB of storage, or the Nextcloud instance is 10GB and with three backups you get a total of 40GB?

Either way, this isn’t big and certainly not enormous on average in 2025 when you can get a 1TB SSD for ~€50. Of course, it’s a different story if you’re using a web hosting service or a VPS, where storage is still expensive compared to local storage.

If by backups you mean the backups created by the Nextcloud updater, and you also have actual backups of your instance, you can delete them and do future updates with the --no-backup option to save some space.

I don’t know how much of that is js.map.

Run find . -type f -name "*.js.map" -exec du -ch {} + to find out :wink:

My shared hosting ā€œserverā€ has 10GB in total.

From a user and admin perspective I’d like to have a toggle that does the clean up whenever I install a new version. One that makes the tradeoff clear: smaller install size but harder to debug.

This means that every installation/upgrade still downloads and unpacks all this data, which loses half of the purpose of removing/reducing the source maps.

If the only purpose is reducing the size on the disk afterward or in a backup - you can run a simple 1-line bash script after an upgrade or during backup.

Re adding the map files in case of needed debug info is harder but maybe not impossible? I don’t know enough of update process and how integrity is maintained with plugins.

In general, it is possible. Especially if there is a single enterprise installation with a specific infrastructure.

But we need something simple enough for the entire community. So that users could create bug reports with a simple copy/screenshot of the browser console. Without an advanced process of applying external source maps on production instance or setting up additional infrastructure components.