Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Redundant mjs files in msg folder?

53 views
Skip to first unread message

Clément Contet

unread,
Feb 1, 2025, 8:02:48 AMFeb 1
to Blockly
Hi all,

I'm trying to optimize the bundle size of my app, and when analyzing what is related to Blockly, I found that for each language included, there is a .mjs file that is identical between all languages.

Capture d’écran 2025-02-01 à 13.52.37.png
Is there a way to strip/merge them to gain some space? (~100ko in my case)

I understand that this may be very tricky regarding the work you already did on the JS modules, but I ask anyway!

Thanks,

Clément

Clément Contet

unread,
Feb 17, 2025, 4:19:33 AMFeb 17
to Blockly
Hi,

I've tried something to avoid this code duplication: https://github.com/clementcontet/blockly/commit/f0ae61efd7e934c17047cf45ad0ae5a6824d9082
I didn't make a pull request because it is more of a proof of concept that "just works" and the subject is very tricky (ESM and CJS modules).
The idea is to avoid repeating the destructuring assignments made in the .mjs for every language, by creating a type (MessageKeys) that is reusable.
In my case, the gain is about 15ko per additional language, but I don't know if it is that frequent to bundle multiple languages in the same app?

What do you think?

Thanks,

Clément

Clément Contet

unread,
Feb 18, 2025, 4:19:58 PMFeb 18
to Blockly
I've finally implemented lazy loading for the language files. It makes the overhead in bundle size less important.

Reply all
Reply to author
Forward
0 new messages