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

Object.freeze/seal prevent removal #3102

Open
jplaisted opened this issue Oct 11, 2018 · 3 comments
Open

Object.freeze/seal prevent removal #3102

jplaisted opened this issue Oct 11, 2018 · 3 comments

Comments

@jplaisted
Copy link
Contributor

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());
}});
jplaisted pushed a commit to google/closure-library that referenced this issue Oct 11, 2018
… is more correct - but in either case there's an issue that this prevents removal.

google/closure-compiler#3102

RELNOTES: n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=216742620
@karikera
Copy link

karikera commented Jun 4, 2020

Could I avoid this situation?

@concavelenz
Copy link
Contributor

@karikera What is your use case?

@karikera
Copy link

karikera commented Jun 6, 2020

@concavelenz
I just use Object.freeze for optimizing.
but it keeps unused variables.

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

No branches or pull requests

3 participants