dart-lang/build

JS interop does not appear to work in tests with build_web_compilers 2.0.0

corwinsheahan-wf opened this issue · 5 comments

Hi there!

We recently began upgrading some of our packages to use build_web_compilers 2.0.0. Unfortunately, we noticed that tests seemed to have issues calling functions from react.js. I was able to create a reduced test case that appears to show that js interop is not working properly in tests with build_web_compilers 2.0.0, which you can find here.

In that package, if you switch the deps to use build_web_compilers 1.x, the test will pass, but on build_web_compilers 2.0.0, the test will fail because it doesn't properly call the js method. I've also verified via using the --pause-after-load flag that the some.js file can be loaded successfully in the browser via the path specified in the test html.

This is on Dart 2.3.0. Thanks for the help!

Duplicate of dart-lang/sdk#36912, note that it is cross-module JS-interop that doesn't work (that is, invoking a function marked as @JS in another library. You can work around the issue by making the actual @JS annotated function be private and making a regular function in the library that delegates to it. Essentially, this:

@JS()
external _foo();

foo() => _foo();

Even though this is a duplicate I will leave it open for now I think so it is easier to find and we don't get a ton more duplicates :).

Note that the core issue in the sdk is resolved here, so the next release should have a fix (stable or dev).

Closing since this should be resolved with the latest SDKs