From 1d816958ecebf2df1060d1f357f012c2eead6783 Mon Sep 17 00:00:00 2001 From: Joe Yates Date: Sun, 24 Mar 2024 11:12:28 +0100 Subject: [PATCH] Bugfix: Avoid dot notation in minified Javascript It is better to use `[]` for object access in Javascript code that is processed by Emscripten. The Javascript libraries passed to emcc are being minified with Google's [Closure Compiler](https://developers.google.com/closure/compiler) due to the `--closure 1` parameter. The closure compiler minifies keys on objects. ```js const mxPathName = vfs.mxPathName ?? 64; ``` is minified as ```js var n=h.Lg??64; ``` where `h.Lg` is undefined, so `n` will always be `64`. With this change, the minified output is ```js var n=h.mxPathName??64; ``` --- src/libvfs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libvfs.js b/src/libvfs.js index e6064f65..997b70a5 100644 --- a/src/libvfs.js +++ b/src/libvfs.js @@ -22,7 +22,7 @@ const vfs_methods = { vfs['handleAsync'] = Asyncify.handleAsync; } - const mxPathName = vfs.mxPathName ?? 64; + const mxPathName = vfs['mxPathName'] ?? 64; const out = Module['_malloc'](4); const result = ccall('register_vfs', 'number', ['string', 'number', 'number', 'number'], [vfs.name, mxPathName, makeDefault ? 1 : 0, out]);