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

js: Update decoder module to be more friendly to Terser #610

Merged
merged 1 commit into from
Oct 5, 2023
Merged

Conversation

zeux
Copy link
Owner

@zeux zeux commented Oct 4, 2023

Terser minifies and mangles JS; since we build WebWorker JS code dynamically as a string, references to identifiers from that string end up being invalid.

To reduce fragility of this code, we no longer rely on module-scoped variables instance and ready, and instead communicate the instance through self.ready promise.

See #609.

Terser minifies and mangles JS; since we build WebWorker JS code
dynamically as a string, references to identifiers from that string end
up being invalid.

To reduce fragility of this code, we no longer rely on module-scoped
variables instance and ready, and instead communicate the instance
through self.ready promise.
@andreasplesch
Copy link

Thanks ! I had not gotten to the point to realize that "instance" and "ready" are also used in the module scope and in the code string.

I tested the new meshopt_decoder.js from the js-terser branch and it worked fine after terser mangling for us ( https:/x3dom/x3dom ) in a test branch, with the default terser options.

The use of workerProcess.name may look a little cryptic but github blame would point back to here to explain if comments are to be kept at a minimum.

@zeux zeux merged commit b50b4ab into master Oct 5, 2023
11 checks passed
@zeux zeux deleted the js-terser branch October 5, 2023 11:48
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.

2 participants