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
const methods -> JSC_REDECLARED_VARIABLE_ERROR: Illegal redeclared variable #2471
Comments
You're running afoul of this externs definition. You don't get an error for |
QuakePhil
added a commit
to QuakePhil/blocks
that referenced
this issue
Sep 9, 2018
… instead of let
crazygolem
added a commit
to crazygolem/markdown-muncher
that referenced
this issue
Aug 7, 2021
The closure compiler has been replaced by terser for the minification step, as closure does not handle correctly variables (or in this case constants) declared with the same name as some globals (in this case `document`). This is a valid error for scripts, but in ES modules this kind of redeclarations do not cause problems (at least for `document`). For details see: - ampproject/rollup-plugin-closure-compiler#92 - google/closure-compiler#3098 - google/closure-compiler#2471
crazygolem
added a commit
to crazygolem/markdown-muncher
that referenced
this issue
Aug 7, 2021
The closure compiler has been replaced by terser for the minification step, as closure does not handle correctly variables (or in this case constants) declared with the same name as some globals (in this case `document`). This is a valid error for scripts, but in ES modules this kind of redeclarations do not cause problems (at least for `document`). For details see: - ampproject/rollup-plugin-closure-compiler#92 - google/closure-compiler#3098 - google/closure-compiler#2471 Also terser is way faster than closure, and produces a slightly smaller minified script.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not sure if this is a bug, or "by design".
Today we found an issue compiling our js code. Somewhere we had a global "const methods". During compilation it throws an error:
The strange thing is that both const and let throw the error, but var doesn't.
These are the flags we use (cmd) during compilation:
Check the link to see the problem in action.
https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F%252F%2520ADD%2520YOUR%2520CODE%2520HERE%250Aconst%2520methods%2520%253D%2520%255B%250A%2520%2520%2520%2520%2520%2520%2520%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520type%253A%2520%255B%2522--help%2522%252C%2520%2522-h%2522%255D%252C%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520func%253A%2520()%2520%253D%253E%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520console.log(%2522Something%2522)%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%255D%253B%250A%250Aif%2520(methods.includes(%2522-h%2522))%2520%257B%250A%2520%2520%2520%2520methods.func()%253B%250A%257D%250A%250A
The text was updated successfully, but these errors were encountered: