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

Created on 10 May 2019  路  5Comments  路  Source: dart-lang/build

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!

Most helpful comment

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

All 5 comments

Duplicate of https://github.com/dart-lang/sdk/issues/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).

Thanks @jakemac53!

Closing since this should be resolved with the latest SDKs

Was this page helpful?
0 / 5 - 0 ratings