-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add badges for Wasm compatibility #6785
Comments
We're not quite ready to define the bits here, but it's good to have a placeholder! |
This should be possible by checking if the package depends on Or any other dependency that does not support WASM (e.g. because it or one of its transitive dependencies depend on the above), right? |
@IchordeDionysos – yep! |
Hmm, okay, the tricky part is that pub.dev does not know whether the package depends on This might have been easily doable (if this was already indexed / available) in the pub.dev database. |
Not sure if this is a typo or not, so just to be specific about it: pub.dev does package analysis (using |
@isoos Actually, in my assumption, I thought the scan would not detect uses of I came to that conclusion as usages of e.g. Definitely nice to hear support for this badge is progressing 🙌 |
There is no filter yet, but this seems to work already 😍 If I'm getting too excited too early and the data is not yet fully up-to-date or if there's another reason it has yet to be added, I'm sorry :D |
We list only package dependencies on the package page (direct ones in the infobox, direct+transient in the package score tab). It may be useful to also expose the SDK library dependencies (
We are still evaluating if the analysis is correct and makes sense. |
Also, almost forgot: if you see something wrong with the tagging (either false positive or false negative), please report it (here or in |
Yeah seen a few where it seemed incorrect, will compile a list. |
@IchordeDionysos This filter shows image_picker and other packages that still don’t support wasm yet or in-progress image_picker still in-progress |
@isoos I think package:pana may need to check for dart:html dart:js dart:js_util package:js in the package or its dependencies like @IchordeDionysos said |
Definition:
intl: false positive i18n_extension: false positive flutter_keyboard_visibility: false positive intercom_flutter: false positive oauth2_client: false positive: sensors_plus: false positive: uni_links: false positive: fetch_client: false negative ??? |
Just uploaded https://pub.dev/packages/flutter_markdown – which I think is wasm-ready, but it's not being labeled |
Looking at I'm pretty sure that But if we were to use |
I guess technically a federated plugin like The plugin does not directly import |
The thing is when you research a package you want it to work on all platforms and not have to write your own implementation for it. |
Yeah, but if I have to choose between false-positive / and true-negative, then in the case of platform tagging, false-positive isn't the worst. But yes, we need to do better at understand flutter plugins. |
I'm actually not sure this is a false-positive. We allow importing It's okay for other (optional) libraries to import it, so For all platform detection we use the primary library (if there is no primary library, we require all libraries). For platform detection we do this because we assume that the primary library will use configurable-imports. And we assume that other libraries might be used to expose additional platform specific functionality. We could ofcourse, require that if you implement platform specific functionality in additional libraries, then you must use configurable imports, such that the same API exists on other platforms, but that instead those platform throws The other cases appears to be flutter plugins, I agree that we should be better at understanding flutter plugins. But I don't know if we want to block on this. |
Could we start with an FYI on the score tab to show how we're evaluating a package? Might be a nice tip-toe into this space without affecting scores |
Not sure where the best place to report general false negatives are, maybe pana (eg. dart-lang/pana#1324) would be more suited, but I think until packages can define that they do or do not support Wasm (as is the case with platforms) in their pubspec, then it will be difficult to do this accurately. For example, 'package:logger' is reported as non-Wasm ready, because one of it's files/internal libraries does a conditional import of 'dart:io' (but the package is not a plugin, and this is the primary library), which means 'package:flutter_map' becomes non-Wasm ready, even though it is proved to build with Wasm. Until maintainers get a way to report Wasm compatibility themselves (as with platforms), then awarding badges might be an issue. Or, pana needs to get better at platform detection for conditional imports. Or, maybe 'package:logger' is just written incorrectly for pana detection? Not sure. |
This should likely be copied to Thoughts @jonasfj ? |
Please file again pana. The problem is that importing |
Ah, I see, so the library is written somewhat incorrectly. What does pana do with conditional imports anyway |
Unlike @kevmoo, @sigurdm this is probably a bit of a hole. wasm isn't really a platform. I suppose we could allow overridding the detection with something like: platform:
web:
wasm: true I don't know, if we're ready to formalize what values goes under @JaffaKetchup at the moment by strong suggestion would be to contributor to |
Yeah, something like that would be what I was looking for 👍 |
Similar issues happen here: False positivemaplibre_gl is marked wasm compatible on pub.dev. It doesn't include dart:io but uses maplibre_gl_web for its web implementation like a lot of other flutter plugins do. The problem is that False negativemaplibre is marked wasm incompatible on pub.dev but runs fine on web with wasm. The web implementation gets registered like documented in the flutter plugin documentation and how it is done in a newly created flutter plugin project. However, the platform channel implementation is directly imported in the platform interface class. Pana detects this and follows the imports to the dart:io imports but does not detect the registered web implementation. Package not compatible with runtime wasm
Because:
package:maplibre/maplibre.dart that imports:
package:maplibre/src/map.dart that imports:
package:maplibre/src/platform_interface.dart that imports:
package:maplibre/src/native/platform_native.dart that imports:
package:maplibre/src/native/widget_state.dart that imports:
dart:io The pana can improve a lot in detecting false positives and false negatives but I'm not sure if it will be possible to be 100% accurate. |
maplibre_gl is a federated plugin, and only imports directly from https://pub.dev/packages/maplibre_gl_platform_interface, which is a generic interface for. One could (at least in theory) plug another wasm-compatible web-implementation in. We could consider it not wasm-compatible if its default implementation is not wasm-compatible. But that is not the current behavior, and not clear that it is correct. (It would also severely make the platform detection less generic.) |
The import here https://github.com/josxha/flutter-maplibre/blob/main/lib/src/platform_interface.dart#L3 should be made conditional, to make the static distinction clear to pana. |
Flutter web plugins are currently using
dart:html
andpackage:js
to wrap JavaScript APIs. The new version of Dart-JavaScript interop will depend onpackage:web
anddart:js_interop
, respectively.This is a proposal to display a "Wasm compatible" badge if the package imports the correct libraries, and "Wasm incompatible" if it is using the old libraries.
cc: @kevmoo @joshualitt
The text was updated successfully, but these errors were encountered: