-
-
Notifications
You must be signed in to change notification settings - Fork 383
-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
[bug] Mangling breaks the code #364
Comments
Hello there! Please try to reproduce the issue with a small code example so we can get to it. |
@sdll Does disabling collapse_vars solve your problem? |
@fabiosantoscode, I will get back when I have more bandwidth. @TrySound, thank you for the suggestion! Everything works well with |
@sdll also have you tried disabling the module:true option? I don't remember whether rollup-plugin-terser minifies every little module or if it minifies the whole thing in the end. If it's the former, you need module:true. If it's the latter, you need module:true in your ejs bundle and module:false in your CJS bundle. |
Alas, @fabiosantoscode, |
Also Terser does not minify or know about node_modules. |
Plugin runs terser for each chunk |
TL;DR: possible workarounds
@sdll in your rollup config, there's a line that says that imports to https://github.com/tensorflow/tfjs-models/pull/229/files#diff-52a7421250b57b207b930d54490cef68R72 Check out more on how the There might be a crazy interaction between one or more of the plugins you're using and the globals option, but I don't believe this could be a Terser bug per se. Variables whose declarations don't appear in the JS source are treated as "free variables", therefore possibly global and possibly an error because the variable is undefined. This hasn't changed since UglifyJS has been forked. I'm sure that imported symbols are properly marked as in-scope, as I've implemented it myself years ago for uglify-es when it was just a separate branch on the UglifyJS repository. Let me know if one of the workarounds works so we can get to the bottom of this issue and inform future googlers of what might be happening here 🔥 🔥 🔥 |
@fabiosantoscode, thanks for looking into the issue!
I will stick to reserving |
@TrySound do you think this might be an issue on Rollup's end or just misconfiguration? |
@sdll Could you provide gist with minified output? @fabiosantoscode Not sure yet. |
@TrySound, do you mean the stack trace with which the demo fails? |
This error is runtime, right? I need to see the code which is fails. |
@TrySound, correct, the demo fails with the error described above if mangling is set to Working example: https://gist.github.com/sdll/1045f53a48856a6b7f17106b144f6c7f Failing example: https://gist.github.com/sdll/0054bc4248207654779e7bdf94ff8e88 If you want to run the demo yourself, first do |
You sure they are not the same? |
@TrySound, my bad. Fixed now. |
This PR adds the DeepLab model together with a demo. ~~There are several issues with the implementation at the moment.~~ Here is the todo list: - [x] **Fix the grayscale-only segmentation maps** ~~The culprit might be [here](https://github.com/tensorflow/tfjs-models/blob/5fa0787a968799f0a614c663f83afb09b7e8f2cb/deeplab/src/utils.ts#L86).~~ **UPDATE 05/06**: The problem was resolved by constructing a single buffer for the translated segmentation map, instead of building the tensor by stacking three separate channel buffers (see [here](218383a)). I do not quite understand why this solves the problem. - [x] **Show performance stats in the demo** - [x] **Add loader for improved UX** - [x] **~~Fix~~ ~~Disable~~ Reserve `tf` to make mangling work** The code uses ES6 features, so I have picked [`rollup-plugin-terser`](https://github.com/TrySound/rollup-plugin-terser) instead of uglify, which breaks on the compilation of the esm module. ~~Terser, however, is pestered with bugs when mangling is enabled: the demo fails to recognise the minified `tf.tidy` function (the error is, say, `t.tidy is not a function`). I might as well revert to uglify after refactoring the code.~~ **UPDATE 06/06**: ~~The problem persists even after playing with the mangling options, with the model missing `predict` method in the debugging mode. I have disabled mangling altogether and reported the issue (terser/terser#364 **UPDATE 29/06**: Mangling works well when `tf` is reserved. See the awesome [explanation](terser/terser#364 (comment)) by @fabiosantoscode why this might be the case. - [x] **Improve docs** - [x] **Add tests** - [x] **Explore quantisation** **UPDATE 07/06**: The models are quantized by default. - [x] Add Cityscapes and ADE20K Labelling Schemes - [x] Change the gif demo to show all models with updated color mappings Please let me know if I am missing anything. cc: @manrajgrover
Closing this due to radio silence. Tag me if a minimal reproduction comes up please. |
Bug report
Version
rollup-plugin-terser@5.0.0
minify()
options usedhttps://github.com/tensorflow/tfjs-models/blob/8f9a0e1de5ebf74742e6f5ad59d0f9c8704bfe06/deeplab/rollup.config.js#L44
terser
inputSee tensorflow/tfjs-models#229.
terser
errorWhen mangling is enabled, running the demo either misses object properties, or fails to find an imported function (e.g.
tf.tidy
, mangled asn
). With mangling disabled, the code works fine.Could you please tell me what might be the cause of the problem?
The text was updated successfully, but these errors were encountered: