Skip to content
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

Switch dart:js and some dart:js_util usages to use static interop #3299

Merged
merged 6 commits into from
Jan 24, 2023

Conversation

parlough
Copy link
Member

@parlough parlough commented Jan 14, 2023

A little initial exploration into static JS interop to replace dartdoc's current usages of dart:js and some usages dart:js_util. This is closer to what JS-interop will likely look like in the future with inline classes, has some size benefits, and will make it easier to enable strict-casts.

Looks like there is even a little size decrease :D - 209244 bytes -> 201998 bytes or a ≈3.5% reduction when compiled with -O4.

@parlough parlough changed the title [WIP] Switch to using static interop in web code Switch dart:js and dart:js_util usages to use static interop Jan 14, 2023
@parlough parlough marked this pull request as ready for review January 14, 2023 21:57
@kevmoo
Copy link
Member

kevmoo commented Jan 19, 2023

@parlough – without loading the diff locally – what's the byte/% delta?

@parlough
Copy link
Member Author

parlough commented Jan 19, 2023

@kevmoo There's very few usages of the APIs here, so the reduction isn't too large: 209244 bytes -> 201998 bytes or a ≈3.5% reduction when compiled with -O4.

Copy link
Member

@srawlins srawlins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me! The staticInterop docs are pretty ... slim. Are there benefits to this?

@kevmoo
Copy link
Member

kevmoo commented Jan 19, 2023 via email

@kevmoo
Copy link
Member

kevmoo commented Jan 19, 2023

This seems fine to me! The staticInterop docs are pretty ... slim. Are there benefits to this?

Yup - dart-lang/site-www#4331

@parlough
Copy link
Member Author

The README for package:js has some extra context too: https://github.com/dart-lang/sdk/tree/main/pkg/js#staticinterop

@@ -1,7 +1,7 @@
import 'package:js/js.dart';
import 'package:js/js_util.dart' as js_util;

@JS()
@JS('Response')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This is fine and suggested to keep, but is unneeded, since FetchResponse has no constructor or static methods, which would be the only time we use this.

@srujzs
Copy link
Contributor

srujzs commented Jan 20, 2023

Super cool to see the changes here, thanks for doing this!

@parlough parlough changed the title Switch dart:js and dart:js_util usages to use static interop Switch dart:js and some dart:js_util usages to use static interop Jan 23, 2023
@kevmoo
Copy link
Member

kevmoo commented Jan 24, 2023

@parlough – are you able to merge – or do you want me to do it?

@parlough
Copy link
Member Author

parlough commented Jan 24, 2023

@kevmoo I don't have commit/write access on dartdoc, so all you :)

@kevmoo kevmoo merged commit 758e185 into dart-lang:master Jan 24, 2023
@parlough parlough deleted the feature/js-static-interop branch January 24, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants