-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
breaking change: static error when importing dart:mirrors on the web #42714
Comments
lgtm |
It might be worth mentioning that it is possible to work around this using conditional imports. Another convention is to move code that depends on mirrors to a separate library. |
ping @Hixie @matanlurey for approval |
sgtm |
lgtm |
Approved |
This change is to make it a static error to import
dart:mirrors
on dart2js and DDC.Previously,
dart:mirrors
was deprecated on Dart for the web since 2.0.0 and both compilers provided empty implementations that throw on every single API. We are changing the behavior from a runtime error to a compile-time error.What can break?
An app or test that imports
dart:mirrors
directly or indirectly, where mirrors is practically unused, and that is only compiled via dart2js, could see this breaking change. After this change such app will now see a compile-time error and not build.Many of our tools, such as
webdev
andflutter
, already disallow usingdart:mirrors
. Developers working on top ofwebdev
using DDC already see a compile-time error ifdart:mirrors
is imported on their application. Flutter web also provides a static error today.For this reason, we believe the majority of users won't be affected by this change. Only those that directly access dart2js or DDC without any additional frameworks, or that run dart2js test directly via
package:test
, are potentially affected. We also know from an earlier accidental breaking change that only 2 users have been affected and both have been able to circumvent this breaking change already.Note also that packages that use
dart:mirrors
are already tagged in pub.dev as Native-only and not compatible for the web.Mitigation
Apps that show a compile-time error need to remove the import to
dart:mirrors
. This may require changing dependencies on packages or fixing upstream packages to avoid the import. Some ways to remove the dependency is to hide it behind a conditional import. Package authors can also create a separate library in their package, so only those that need the functionality purposely import the dependency on mirrors.@franklinyow @mit-mit @vsmenon @kevmoo
@Hixie @matanlurey for approvals
The text was updated successfully, but these errors were encountered: