question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set property as extern when compiling in ADVANCED level

See original GitHub issue

Hi guys,

First of all, I’m new to closure-compiler, so please bear with me.

I’m unable to get my web worker module (below snippet) to work with closure-compiler when using the ADVANCED level.

$ closure-compiler --compilation_level ADVANCED --js trock.js
var tRock;
self.addEventListener('message', (ev) => {
    /** @const */
    const msg = ev.data;

    switch(msg.tag) {
    case 'upload':
        tRock = msg.ep.tRock; // <------- error happens here after it's compiled
        [...]
        break;
    default:
        //console.error("unexpected msg from main thread", msg);
        self.close();
    }
});

When the compiler runs, it changes this:


switch(msg.tag) {
    case 'upload':
        tRock = msg.ep.tRock

to:

switch(a) {
    case 'upload':
        k=a.a.g

How i can prevent renaming msg.ep ? I tried to put /** @const */, but it had no impact.

As this is a web worker, the ev message is received from elsewhere and the compiler should not rename its properties.

I was expecting the following correct output:

switch(a.tag) {
    case 'upload':
      k=a.ep.tRock

Help appreciated. Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
tjgqcommented, Nov 19, 2020

I think we’re missing the extern for replaceAll - I don’t see it anywhere in es[356].js.

0reactions
Zabranecommented, Jan 17, 2021

@brad4d thank you very much. With your advices and nice tutorial, we are now able to fully benefit from closure-compiler avanced level in a much larger project involving WebWorkers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an undefined reference/unresolved external symbol ...
I just came across another possible reason for the unresolved symbol compiler error. A function was originally defined as inline inside a header,...
Read more >
Linker Tools Error LNK2019 - Microsoft Learn
If the error message is similar to unresolved external symbol WinMain referenced in function function_name, link by using /SUBSYSTEM:CONSOLE ...
Read more >
Top 10 C++ header file mistakes and how to fix them
Recommendation: Check your header filies by compiling them in isolation via a testMain.cpp that includes nothing but the header file under test.
Read more >
Advanced Compilation | Closure Compiler - Google Developers
The solution in this situation is to implement a set of externs defining the public API of your library. Your code will supply...
Read more >
Understanding "extern" keyword in C - GeeksforGeeks
This program throws an error in the compilation(during the linking phase, more info here) because var is declared but not defined anywhere.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found