google / google/closure-compiler
Static methods lost using ES6 modules
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
In advanced obfuscation, the method "something" is removed from the compiled output.
``` javascript
class A {
method() { console.log("instance method"); }
static something() {
console.log("something static");
new A().method();
}
}
export default A;
```
``` javascript
import A from "A"
A.something(); // fails at runtime, [obfuscated name] is not a function
```
I'm guessing this is specific to ES6 modules, since I use classes and static methods with goog.module successfully.
I tried to set up a debugger but don't know how ES6 module paths work there:
https://closure-compiler-debugger.appspot.com/#input0%3Dclass%2520A%2520%257B%250A%250A%2520%2520method()%2520%257B%250A%2520%2520%2520%2520console.log(%2522instance%2520method%2522)%253B%250A%2520%2520%257D%250A%250A%2520%2520static%2520something()%2520%257B%250A%2520%2520%2520%2520console.log(%2522something%2520static%2522)%253B%250A%2520%2520%2520%2520new%2520A().method()%253B%250A%2520%2520%257D%250A%257D%250A%250Aexport%2520default%2520A%253B%250A%26input1%3Dimport%2520A%2520from%2520%2522A%2522%250A%250AA.something()%253B%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26CHECK_TYPES%3D1%26CLOSURE_PASS%3D1%26LANG_IN_IS_ES6%3D1%26MISSING_PROPERTIES%3D1%26PRESERVE_TYPE_ANNOTATIONS%3D1%26PRETTY_PRINT%3D1%26REMOVE_DEAD_CODE%3D1%26REMOVE_UNUSED_CLASS_PROPERTIES%3D1%26TRANSPILE%3D1
Contributor guide
Assessment
This issue has not been assessed yet.