Comments (4)
Code incompatible with the assumptions made by variable or property renaming is likely also incompatible with other advanced optimizations, like method devirtualization and inlining.
I think allowing disabling just renaming in advanced optimziations mode gives a false sense of security that an app will work. Instead it can hit more subtle bugs later on in other optimizations.
(@concavelenz wrote up some thoughts on this recently, so tagging him)
Why do you want to just disable renaming? Is it a problem with optimized code not working, or something else?
from closure-compiler.
Apart from being able to debug the translated code, I am looking into exposing some methods to third-party JavaScript.
I wonder how not renaming types could break the app. Since the operation is only prevented when invoking
via the CommandLineRunner, I wonder if it should be enforced in the first place.
from closure-compiler.
To debug the output code, enable "pseudo renaming" mode with the --debug
flag.
To expose methods to 3p JavaScript, either explicitly expose/export those methods (https://developers.google.com/closure/compiler/docs/externs-and-exports) or fall back to SIMPLE optimizations.
I wonder how not renaming types could break the app.
I'm not saying that not renaming types may break the app. Rather, code that doesn't follow Closure Compiler ADVANCED mode assumptions around when it's safe to rename, will almost certainly fail to conform to other ADVANCED mode assumptions.
Part of the confusion may be terminology. The optimizations controlled by this "renaming" flag are two specific variable and property renaming passes, but they aren't the only compiler passses that may rename properties. For example, method devirtualization may transform Button.prototype.setName
to JSCompiler_methods_setName
, and property flattening may transform my_project.init
to my_project$init
.
Dead-code elimination and inlining can also cause problems. For example, if you wanted to expose some method Button.prototype.setName
for 3p code but don't reference it in your app otherwise, dead-code elimination could delete it.
from closure-compiler.
That makes sense. Thanks for the clarification, @lauraharker !
from closure-compiler.
Related Issues (20)
- ADVANCED compilation mode produces code in wrong execution order HOT 9
- Bug: static class members defined via an IIFE cause the class to not be removed HOT 1
- ES2020 private members not supported HOT 1
- Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" HOT 2
- import/export directives ignored when not at the start of line HOT 2
- `var` is not hoisted to the nearest variable scope HOT 1
- add getTargetRanges()
- Compiler crashes with dymamic imports (`IllegalStateException`) HOT 3
- com.google.guava vulnerability issue in closure-compiler-20220502 HOT 4
- Assigning a variable while passing to a function fails AC HOT 6
- A for loop compiles incorrectly in WHITESPACE_ONLY and SIMPLE_OPTIMIZATIONS HOT 3
- "Copyright The Closure Library Authors" always shows up as the first comment even in code that is ultimately not Apache 2.0 licensed HOT 2
- ADVANCED compilation mode incorrectly removes non-dead code HOT 7
- BUG in Whitespace only for online compiler
- Extern definitions for WebGPU HOT 4
- Google Closure Compiler on Mac with M3 chip HOT 2
- Concatenated template literals are not merged
- java.lang.RuntimeException: INTERNAL COMPILER ERROR. HOT 3
- INTERNAL COMPILER ERROR: Cannot invoke "com.google.javascript.rhino.PMap.isEmpty()" because "that" is null HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from closure-compiler.