Skip to content

Commit 1d81695

Browse files
committed
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; ```
1 parent f1f8550 commit 1d81695

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libvfs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const vfs_methods = {
2222
vfs['handleAsync'] = Asyncify.handleAsync;
2323
}
2424

25-
const mxPathName = vfs.mxPathName ?? 64;
25+
const mxPathName = vfs['mxPathName'] ?? 64;
2626
const out = Module['_malloc'](4);
2727
const result = ccall('register_vfs', 'number', ['string', 'number', 'number', 'number'],
2828
[vfs.name, mxPathName, makeDefault ? 1 : 0, out]);

0 commit comments

Comments
 (0)