google / google/closure-compiler

Object.freeze/seal prevent removal

Open
#3,102 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Closure Library's new goog.js file has the following:

```
export const module = Object.seal({
get: goog.module.get,
// TODO(johnplaisted): Delete this once people have migrated to
// declareModuleId.
declareNamespace: goog.module.declareNamespace,
});
```

In compiled output this won't get removed, even when it isn't referenced (and `RewriteGoogJsImports` should ensure it isn't referenced after it runs...).

```
var b = this;
Object.seal({get:function() {
return null;
}, b:function(c) {
var a = b.$jscomp;
if (!a || "function" != typeof a.a) {
throw Error('Module with namespace "' + c + '" has been loaded incorrectly.');
}
a.c(a.a());
}});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.