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

Bugfix: Avoid dot notation in minified Javascript #163

Merged
merged 1 commit into from
Mar 25, 2024
Merged

Bugfix: Avoid dot notation in minified Javascript #163

merged 1 commit into from
Mar 25, 2024

Conversation

joeyates
Copy link
Contributor

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
due to the --closure 1 parameter.
The closure compiler minifies keys on objects.

const mxPathName = vfs.mxPathName ?? 64;

is minified as

var n=h.Lg??64;

where h.Lg is undefined, so n will always be 64.

With this change, the minified output is

var n=h.mxPathName??64;

Checklist

  • I grant to recipients of this Project distribution a perpetual,
    non-exclusive, royalty-free, irrevocable copyright license to reproduce, prepare
    derivative works of, publicly display, sublicense, and distribute this
    Contribution and such derivative works.
  • I certify that I am legally entitled to grant this license, and that this
    Contribution contains no content requiring a license from any third party.

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;
```
@rhashimoto
Copy link
Owner

Ah, good catch! Thanks!

@rhashimoto rhashimoto merged commit d2a2f1c into rhashimoto:master Mar 25, 2024
1 check passed
@joeyates joeyates deleted the fix/avoid-dot-notation-with-mangled-names branch March 25, 2024 07:36
@joeyates
Copy link
Contributor Author

@rhashimoto Any plans for a new release?

@rhashimoto
Copy link
Owner

@joeyates I'll cut one soon. There's one more thing I want to include.

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

Successfully merging this pull request may close these issues.

None yet

2 participants