Add a dart2js option to fail early for dart:io imports
Opened this issue · 2 comments
Currently our production tool stacks, webdev and bazel, implement their own platform restrictions for core library imports. The check is done for individual modules.
When compiling with dart2js for running web tests, the test runner does monolithic compiles and has no understanding of imports.
Can we have a flag to ask dart2js to eagerly fail for imports that are unsupported?
The flag should be fairly simple to add, and I support having it.
Note: we've considered a breaking change that disallow imports to dart:io altogether on the web, see #46917. Unfortunately that kind of breaking change will be expensive to push through and probably not something we want to take on at this point in time (FYI @mit-mit). That said, I can see this flag being also useful to manage an incremental migration when we do move forward with such breaking change.
@johnniwinther - this is one of the relevant bugs from our conversation earlier today.
In our conversation I mentioned I'm open to consider this breaking change in the future, but reading again through the example from Slava in #46917 (comment), I think that will be a big effort and not easy to achieve in the Dart 3 timeline.
Having a flag and an incremental migration path may be the right strategy here.