prepack icon indicating copy to clipboard operation
prepack copied to clipboard

External Event Handlers

Open s5bug opened this issue 6 years ago • 2 comments

I'm dealing with code.org's AppLab for one of my projects. I'm using Scala and compiling to Scala.JS.

This Scala registers event handlers to AppLab's onEvent function but prepack is recognizing it as dead code.

How do I properly handle/configure this case? (There are other functions that mutate external state as well, like button, setPosition, setText that I use in my code, but I handle these with the function described in #619)

s5bug avatar Feb 19 '19 03:02 s5bug

This Scala registers event handlers to AppLab's onEvent function but prepack is recognizing it as dead code.

Do you have a small self-contained example that illustrates the issue?

NTillmann avatar Apr 10 '19 18:04 NTillmann

It seems the behavior has changed now (or prepack is unable to correctly infer behavior from the ScalaJS code).

__assumeDataProperty(global, "onEvent", __abstract("function", "onEvent"));

(function() {
  onEvent("onClick", "foo", function(e) {
    console.log("hi")
  })
}).call(this);

Error on line 4.

I just recently reset my computer to free up space so I don't have a ScalaJS file to test at the moment. I'll get one as soon as time allows.

s5bug avatar Apr 10 '19 20:04 s5bug