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

Move package:web dependency to dev dependency #139696

Merged
merged 14 commits into from Dec 15, 2023
Merged

Conversation

srujzs
Copy link
Contributor

@srujzs srujzs commented Dec 6, 2023

Pinning the package:web dependency constrains downstream packages from using newer versions and making sure they support the version pinned in Flutter. Since the usage of package:web in Flutter is light, we should instead have a small shim like the engine and keep package:web as a dev dependency only.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

Pinning the package:web dependency constrains downstream packages
from using newer versions and making sure they support the version
pinned in Flutter. Since the usage of package:web in Flutter is
light, we should instead have a small shim like the engine and keep
package:web as a dev dependency only.
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. a: internationalization Supporting other languages or locales. (aka i18n) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin labels Dec 6, 2023
@srujzs
Copy link
Contributor Author

srujzs commented Dec 7, 2023

There's an open question on where web.dart (our shim) should go and what it should be named. Right now, I'm getting a bunch of public_member_api_docs lints, but I don't think we should annotate all these interop types with documentation when that should go in package:web. Should I silence those lints? Move this file to somewhere where those lints don't apply?

@@ -421,8 +421,8 @@ class HtmlElementView extends StatelessWidget {
/// used by the app to customize the element by adding attributes and styles.
///
/// ```dart
/// import 'package:flutter/src/web.dart' as web;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is okay :)

Copy link
Contributor

Choose a reason for hiding this comment

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

What was wrong with the old code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dartdoc/analysis would attempt to run this code, but because package:web is no longer a dependency, it would not resolve.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for derailing the PR, but I'm starting to have second thoughts about it:

This example is meant to work when developers copy it into their apps, but it looks like it won't? This might be an indicator that removing the dependency on package:web may not be a good idea. If users are expected to use the core framework APIs along with package:web then for all intents and purposes the framework already depends on it despite the hacks we use to sever the dependency for pub get's sake.

Maybe we should pay the cost of pinning so our developers do not pay the cost of poor ergonomics. In fact, now that I think about this class, it is a web-specific class but it lives in the platform-agnostic widgets/platform_view.dart library. We should move it into its own widgets/platform_view_web.dart library and teach it to speak in terms of package:web interfaces instead of Object. That library will be imported behind a conditionally imported library that has access to web-specific libraries, including package:web.

Copy link
Contributor

Choose a reason for hiding this comment

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

For EXAMPLES, folks SHOULD use pkg:web.

Casting works fine. Types are erased.
@srujzs is just working around tooling silly here.

That's the beauty here. Let's lean into it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should still work. This is an analysis issue that is specific to the doc comment. Users should still import package:web/web.dart and the code will still work fine even with the shim we introduce here. @staticInterop (and later, extension types on JSObject) can be casted freely from one type to another unlike dart:html types, because we only ever check that the type is a JSObject. I don't want people to be able to use the shim besides for the purpose in this CL.

If we want to treat this comment as a guide for users (which I agree we should), then it's a matter of ignoring that analysis issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about we move the example to flutter.dev and remove it from the docs?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM! At a minimum just open the issue. This can go in our embedding docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the example from this PR and filed https://github.com/flutter/flutter/issues/140010.

/// Flutter as a dependency.
///
/// This should stay in sync with `package:web` as much as possible to make it
/// easier to add new members as needed.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the process for keeping it in sync with package:web? Is this file generated? If so, we should document the process for regenerating it. If it's manually written, we should document the guidelines for maintaining it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is indeed manually copied over. I've added a few comments guiding users on how to maintain and extend it, let me know if there needs to be more, thanks!

@@ -421,8 +421,8 @@ class HtmlElementView extends StatelessWidget {
/// used by the app to customize the element by adding attributes and styles.
///
/// ```dart
/// import 'package:flutter/src/web.dart' as web;
Copy link
Contributor

Choose a reason for hiding this comment

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

What was wrong with the old code?

@srujzs
Copy link
Contributor Author

srujzs commented Dec 11, 2023

Friendly ping on this.

@kevmoo kevmoo added the e: wasm Issues related to the wasm build of Flutter Web. label Dec 12, 2023
@srujzs
Copy link
Contributor Author

srujzs commented Dec 12, 2023

There's an open question on where web.dart (our shim) should go and what it should be named. Right now, I'm getting a bunch of public_member_api_docs lints, but I don't think we should annotate all these interop types with documentation when that should go in package:web. Should I silence those lints? Move this file to somewhere where those lints don't apply?

FYI - I've ignored these lints for the file for now and documented why.

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 13, 2023
Copy link
Contributor

auto-submit bot commented Dec 15, 2023

auto label is removed for flutter/flutter/139696, due to Pull request flutter/flutter/139696 is not in a mergeable state.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 15, 2023
@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 15, 2023
@github-actions github-actions bot removed the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 15, 2023
@srujzs srujzs merged commit 2407f69 into flutter:master Dec 15, 2023
137 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 15, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Dec 15, 2023
flutter/flutter@a51e33a...2407f69

2023-12-15 58529443+srujzs@users.noreply.github.com Move package:web dependency to dev dependency (flutter/flutter#139696)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9524a185b055 to 986a6fe198dc (1 revision) (flutter/flutter#140221)
2023-12-15 engine-flutter-autoroll@skia.org Roll Packages from 1151191 to 3f2e16b (9 revisions) (flutter/flutter#140218)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7a50221733c2 to 9524a185b055 (1 revision) (flutter/flutter#140217)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 767223f7a4f8 to 7a50221733c2 (1 revision) (flutter/flutter#140216)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 91f65eea0c11 to 767223f7a4f8 (1 revision) (flutter/flutter#140210)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from a47da28c9a62 to 91f65eea0c11 (1 revision) (flutter/flutter#140207)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from cde1a596432d to a47da28c9a62 (1 revision) (flutter/flutter#140204)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 46ff5c08a905 to cde1a596432d (1 revision) (flutter/flutter#140200)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from a17bb0a63b7e to 46ff5c08a905 (1 revision) (flutter/flutter#140198)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4cb3ba7a85f6 to a17bb0a63b7e (1 revision) (flutter/flutter#140196)
2023-12-15 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0e7248d43251 to 4cb3ba7a85f6 (14 revisions) (flutter/flutter#140195)
2023-12-15 polinach@google.com Increase versions of leak tracker libraries. (flutter/flutter#140018)
2023-12-15 magder@google.com Set compile test iOS app target version to not embed Swift runtime (flutter/flutter#140188)
2023-12-15 58190796+MitchellGoodwin@users.noreply.github.com Cupertino text clear label (flutter/flutter#129727)
2023-12-15 xilaizhang@google.com [github actions] use token from real user flutter mirror bot  (flutter/flutter#140191)
2023-12-15 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Flutter Engine from 0e7248d43251 to 0b0fab821536 (4 revisions)" (flutter/flutter#140194)
2023-12-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0e7248d43251 to 0b0fab821536 (4 revisions) (flutter/flutter#140180)
2023-12-14 lsaudon@gmail.com feat: Add onTapAlwaysCalled in TextFormField (flutter/flutter#140089)
2023-12-14 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 3.1.3 to 4.0.0 (flutter/flutter#140177)
2023-12-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2140942444ea to 0e7248d43251 (2 revisions) (flutter/flutter#140176)
2023-12-14 ybz975218925@gmail.com fix reorderable_list drop animation (flutter/flutter#139362)
2023-12-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from 997d3dfa1e74 to 2140942444ea (4 revisions) (flutter/flutter#140171)
2023-12-14 38147403+sharmashashi@users.noreply.github.com Fix BottomNavigationBarItem label overflow (flutter/flutter#120206)
2023-12-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from a565cea256c7 to 997d3dfa1e74 (2 revisions) (flutter/flutter#140170)
2023-12-14 chingjun@google.com Revert "Dynamic view sizing" (flutter/flutter#140165)
2023-12-14 aki.nishi.work@gmail.com �: fix cupertionActionSheet design (flutter/flutter#134345)
2023-12-14 104349824+huycozy@users.noreply.github.com Make improvements to existing new issue templates  (flutter/flutter#140142)
2023-12-14 engine-flutter-autoroll@skia.org Roll Flutter Engine from caf33276468b to a565cea256c7 (1 revision) (flutter/flutter#140163)
2023-12-14 parlough@gmail.com Expand and update a few release.yml categories (flutter/flutter#140120)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC dit@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@XilaiZhang XilaiZhang added cp: beta cherry pick this pull request to beta release candidate branch and removed cp: beta cherry pick this pull request to beta release candidate branch labels Dec 15, 2023
@CaseyHillers CaseyHillers added the revert Autorevert PR (with "Reason for revert:" comment) label Dec 15, 2023
Copy link
Contributor

auto-submit bot commented Dec 16, 2023

Unable to create the revert pull request due to ProcessException: Standard out
Auto-merging dev/a11y_assessments/pubspec.yaml
CONFLICT (content): Merge conflict in dev/a11y_assessments/pubspec.yaml
Auto-merging dev/automated_tests/pubspec.yaml
CONFLICT (content): Merge conflict in dev/automated_tests/pubspec.yaml
Auto-merging dev/benchmarks/complex_layout/pubspec.yaml
CONFLICT (content): Merge conflict in dev/benchmarks/complex_layout/pubspec.yaml
Auto-merging dev/benchmarks/microbenchmarks/pubspec.yaml
CONFLICT (content): Merge conflict in dev/benchmarks/microbenchmarks/pubspec.yaml
Auto-merging dev/benchmarks/platform_channels_benchmarks/pubspec.yaml
CONFLICT (content): Merge conflict in dev/benchmarks/platform_channels_benchmarks/pubspec.yaml
Auto-merging dev/benchmarks/platform_views_layout/pubspec.yaml
CONFLICT (content): Merge conflict in dev/benchmarks/platform_views_layout/pubspec.yaml
Auto-merging dev/benchmarks/platform_views_layout_hybrid_composition/pubspec.yaml
CONFLICT (content): Merge conflict in dev/benchmarks/platform_views_layout_hybrid_composition/pubspec.yaml
Auto-merging dev/benchmarks/test_apps/stocks/pubspec.yaml
CONFLICT (content): Merge conflict in dev/benchmarks/test_apps/stocks/pubspec.yaml
Auto-merging dev/bots/allowlist.dart
Auto-merging dev/integration_tests/android_embedding_v2_smoke_test/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/android_embedding_v2_smoke_test/pubspec.yaml
Auto-merging dev/integration_tests/android_semantics_testing/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/android_semantics_testing/pubspec.yaml
Auto-merging dev/integration_tests/android_views/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/android_views/pubspec.yaml
Auto-merging dev/integration_tests/channels/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/channels/pubspec.yaml
Auto-merging dev/integration_tests/deferred_components_test/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/deferred_components_test/pubspec.yaml
Auto-merging dev/integration_tests/flavors/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/flavors/pubspec.yaml
Auto-merging dev/integration_tests/hybrid_android_views/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/hybrid_android_views/pubspec.yaml
Auto-merging dev/integration_tests/ios_add2app_life_cycle/flutterapp/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/ios_add2app_life_cycle/flutterapp/pubspec.yaml
Auto-merging dev/integration_tests/ios_app_with_extensions/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/ios_app_with_extensions/pubspec.yaml
Auto-merging dev/integration_tests/ios_platform_view_tests/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/ios_platform_view_tests/pubspec.yaml
Auto-merging dev/integration_tests/non_nullable/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/non_nullable/pubspec.yaml
Auto-merging dev/integration_tests/release_smoke_test/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/release_smoke_test/pubspec.yaml
Auto-merging dev/integration_tests/spell_check/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/spell_check/pubspec.yaml
Auto-merging dev/integration_tests/ui/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/ui/pubspec.yaml
Auto-merging dev/integration_tests/web_e2e_tests/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/web_e2e_tests/pubspec.yaml
Auto-merging dev/integration_tests/wide_gamut_test/pubspec.yaml
CONFLICT (content): Merge conflict in dev/integration_tests/wide_gamut_test/pubspec.yaml
Auto-merging dev/manual_tests/pubspec.yaml
CONFLICT (content): Merge conflict in dev/manual_tests/pubspec.yaml
Auto-merging dev/tools/vitool/pubspec.yaml
CONFLICT (content): Merge conflict in dev/tools/vitool/pubspec.yaml
Auto-merging dev/tracing_tests/pubspec.yaml
CONFLICT (content): Merge conflict in dev/tracing_tests/pubspec.yaml
Auto-merging examples/api/pubspec.yaml
CONFLICT (content): Merge conflict in examples/api/pubspec.yaml
Auto-merging examples/hello_world/pubspec.yaml
CONFLICT (content): Merge conflict in examples/hello_world/pubspec.yaml
Auto-merging examples/image_list/pubspec.yaml
CONFLICT (content): Merge conflict in examples/image_list/pubspec.yaml
Auto-merging examples/layers/pubspec.yaml
CONFLICT (content): Merge conflict in examples/layers/pubspec.yaml
Auto-merging examples/platform_channel/pubspec.yaml
CONFLICT (content): Merge conflict in examples/platform_channel/pubspec.yaml
Auto-merging examples/platform_channel_swift/pubspec.yaml
CONFLICT (content): Merge conflict in examples/platform_channel_swift/pubspec.yaml
Auto-merging examples/splash/pubspec.yaml
CONFLICT (content): Merge conflict in examples/splash/pubspec.yaml
Auto-merging examples/texture/pubspec.yaml
CONFLICT (content): Merge conflict in examples/texture/pubspec.yaml
Auto-merging packages/flutter/pubspec.yaml
Auto-merging packages/flutter/test/painting/_network_image_test_web.dart
Auto-merging packages/flutter/test_private/test/pubspec.yaml
CONFLICT (content): Merge conflict in packages/flutter/test_private/test/pubspec.yaml
Auto-merging packages/flutter_driver/pubspec.yaml
CONFLICT (content): Merge conflict in packages/flutter_driver/pubspec.yaml
Auto-merging packages/flutter_goldens/pubspec.yaml
CONFLICT (content): Merge conflict in packages/flutter_goldens/pubspec.yaml
Auto-merging packages/flutter_localizations/pubspec.yaml
CONFLICT (content): Merge conflict in packages/flutter_localizations/pubspec.yaml
Auto-merging packages/flutter_test/pubspec.yaml
CONFLICT (content): Merge conflict in packages/flutter_test/pubspec.yaml
Auto-merging packages/flutter_web_plugins/pubspec.yaml
CONFLICT (content): Merge conflict in packages/flutter_web_plugins/pubspec.yaml
Auto-merging packages/integration_test/example/pubspec.yaml
CONFLICT (content): Merge conflict in packages/integration_test/example/pubspec.yaml
Auto-merging packages/integration_test/pubspec.yaml
CONFLICT (content): Merge conflict in packages/integration_test/pubspec.yaml
Standard error
error: could not revert 2407f69... Move package:web dependency to dev dependency (#139696)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git revert --continue".
hint: You can instead skip this commit with "git revert --skip".
hint: To abort and get back to the state before "git revert",
hint: run "git revert --abort".
Command: git revert --no-edit -m 1 2407f69

@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Dec 16, 2023
@CaseyHillers
Copy link
Contributor

FYI this broke Google testing. Please take a look at b/316639209

srujzs added a commit to srujzs/flutter that referenced this pull request Dec 16, 2023
Michal-MK pushed a commit to Michal-MK/flutter that referenced this pull request Jan 8, 2024
Pinning the package:web dependency constrains downstream packages from
using newer versions and making sure they support the version pinned in
Flutter. Since the usage of package:web in Flutter is light, we should
instead have a small shim like the engine and keep package:web as a dev
dependency only.
Markzipan pushed a commit to Markzipan/flutter that referenced this pull request Jan 9, 2024
Pinning the package:web dependency constrains downstream packages from
using newer versions and making sure they support the version pinned in
Flutter. Since the usage of package:web in Flutter is light, we should
instead have a small shim like the engine and keep package:web as a dev
dependency only.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: internationalization Supporting other languages or locales. (aka i18n) a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos e: wasm Issues related to the wasm build of Flutter Web. f: integration_test The flutter/packages/integration_test plugin framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants