-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[tool][web] Create an early web plugin_registrant for dartpad. #106921
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
[tool][web] Create an early web plugin_registrant for dartpad. #106921
Conversation
|
/cc @srawlins hey Sam, is |
That should be fine. =) |
packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart
Outdated
Show resolved
Hide resolved
|
@domesticmouse once this lands, should we attempt to cherry-pick this fix into Also: can you verify the fix from this branch, or do we need to land this? |
Jasguerrero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is only an issue in beta, so no stable cherry pick is required. It's easiest for me to verify once it is in a named beta branch. I'd have to do some investigation to figure out how to get the tooling to work with master |
|
@domesticmouse AFAIK once this lands, we can request a cherry-pick to |
|
I didn't know about a cherry pick for beta. I thought we just rolled beta weekly on the way to stable. And yes, DartPad is blocked from updating it's beta backend until this lands. |
|
@domesticmouse created the CP request for beta here: #106983 |
|
Under what conditions will $ flutter --version
Flutter 3.3.0-0.0.pre • channel beta • https://github.com/flutter/flutter
Framework • revision f90da9b167 (2 days ago) • 2022-07-18 18:59:23 -0700
Engine • revision 1388adb442
Tools • Dart 2.18.0 (build 2.18.0-271.2.beta) • DevTools 2.15.0
$ flutter pub get
Running "flutter pub get" in simple_project... 4.4s
$ ls -laR
total 64
drwxr-xr-x 7 brettmorgan primarygroup 224 Jul 21 12:49 .
drwxr-xr-x 17 brettmorgan primarygroup 544 Jul 21 12:48 ..
drwxr-xr-x 5 brettmorgan primarygroup 160 Jul 21 12:49 .dart_tool
-rw-r--r-- 1 brettmorgan primarygroup 2054 Jul 21 12:49 .flutter-plugins
-rw-r--r-- 1 brettmorgan primarygroup 7151 Jul 21 12:49 .flutter-plugins-dependencies
-rw-r--r-- 1 brettmorgan primarygroup 15018 Jul 21 12:49 pubspec.lock
-rw-r--r-- 1 brettmorgan primarygroup 2193 Jul 21 12:48 pubspec.yaml
./.dart_tool:
total 88
drwxr-xr-x 5 brettmorgan primarygroup 160 Jul 21 12:49 .
drwxr-xr-x 7 brettmorgan primarygroup 224 Jul 21 12:49 ..
-rw-r--r-- 1 brettmorgan primarygroup 18607 Jul 21 12:49 package_config.json
-rw-r--r-- 1 brettmorgan primarygroup 16871 Jul 21 12:49 package_config_subset
-rw-r--r-- 1 brettmorgan primarygroup 13 Jul 21 12:49 versionContents of name: simple_project
environment:
sdk: '>=2.18.0-0 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_test:
sdk: flutter
archive: 3.3.1
async: 2.9.0
bloc: 8.0.3
boolean_selector: 2.1.0
characters: 1.2.1
clock: 1.1.1
cloud_firestore: 3.3.0
cloud_firestore_platform_interface: 5.6.0
cloud_firestore_web: 2.7.0
collection: 1.16.0
crypto: 3.0.2
english_words: 4.0.0
fake_async: 1.3.1
ffi: 2.0.1
file: 6.1.2
firebase_analytics: 9.2.0
firebase_analytics_platform_interface: 3.2.0
firebase_analytics_web: 0.4.1
firebase_auth: 3.4.2
firebase_auth_platform_interface: 6.3.2
firebase_auth_web: 4.0.0
firebase_core: 1.19.2
firebase_core_platform_interface: 4.4.3
firebase_core_web: 1.7.0
firebase_database: 9.0.19
firebase_database_platform_interface: 0.2.1+11
firebase_database_web: 0.2.1
firebase_messaging: 12.0.0
firebase_messaging_platform_interface: 4.0.0
firebase_messaging_web: 3.0.0
firebase_storage: 10.3.2
firebase_storage_platform_interface: 4.1.11
firebase_storage_web: 3.3.0
flame: 1.2.1
flame_fire_atlas: 1.2.0
flame_forge2d: 0.12.1
flame_splash_screen: 0.1.0
flame_tiled: 1.6.0
flutter_bloc: 8.0.1
flutter_hooks: 0.18.5+1
flutter_lints: 2.0.1
flutter_riverpod: 1.0.4
forge2d: 0.11.0
go_router: 4.1.1
google_fonts: 3.0.1
hooks_riverpod: 1.0.4
http: 0.13.4
http_parser: 4.0.1
intl: 0.17.0
js: 0.6.4
lints: 2.0.0
logging: 1.0.2
matcher: 0.12.12
material_color_utilities: 0.1.5
meta: 1.8.0
nested: 1.0.0
ordered_set: 5.0.0
path: 1.8.2
path_provider: 2.0.11
path_provider_android: 2.0.16
path_provider_ios: 2.0.10
path_provider_linux: 2.1.7
path_provider_macos: 2.0.6
path_provider_platform_interface: 2.0.4
path_provider_windows: 2.1.0
petitparser: 5.0.0
platform: 3.1.0
plugin_platform_interface: 2.1.2
process: 4.2.4
provider: 6.0.3
riverpod: 1.0.3
rxdart: 0.27.5
source_span: 1.9.0
stack_trace: 1.10.0
state_notifier: 0.7.2+1
stream_channel: 2.1.0
string_scanner: 1.1.1
term_glyph: 1.2.1
test_api: 0.4.12
tiled: 0.8.4
typed_data: 1.3.1
vector_math: 2.1.2
win32: 2.7.0
xdg_directories: 0.2.0+1
xml: 5.4.1 |
|
@domesticmouse the file should be created when there's any web plugin declared in the dependencies (it uses the same logic as If you're using
Otherwise you'll be using a cached version of the flutter_tools, and you won't get the new behavior from beta at all. PS: This is what the Once you've deleted the files, you'll get a |
|
Hey @ditman, here's what I'm seeing: $ rm ~/flutter/bin/cache/flutter_tools.s*
$ flutter --version
Building flutter tool...
Flutter 3.3.0-0.0.pre • channel beta • https://github.com/flutter/flutter
Framework • revision f90da9b167 (2 days ago) • 2022-07-18 18:59:23 -0700
Engine • revision 1388adb442
Tools • Dart 2.18.0 (build 2.18.0-271.2.beta) • DevTools 2.15.0
$ flutter pub get
Running "flutter pub get" in simple_project... 4.3s
$ ls -l .dart_tool
total 88
-rw-r--r-- 1 brettmorgan primarygroup 18607 21 Jul 13:45 package_config.json
-rw-r--r-- 1 brettmorgan primarygroup 16871 21 Jul 13:45 package_config_subset
-rw-r--r-- 1 brettmorgan primarygroup 13 21 Jul 13:45 versionWhat am I missing? |
|
OK, switched to beta, and with your same pubspec.yaml, I only added an extra $ flutter --version
Flutter 3.3.0-0.0.pre • channel unknown • unknown source
Framework • revision f90da9b167 (2 days ago) • 2022-07-18 18:59:23 -0700
Engine • revision 1388adb442
Tools • Dart 2.18.0 (build 2.18.0-271.2.beta) • DevTools 2.15.0
$ rm ~/github/flutter/bin/cache/flutter_tools.*
$ flutter clean
Building flutter tool...
Deleting .dart_tool... 3ms
Deleting Generated.xcconfig... 0ms
Deleting flutter_export_environment.sh... 0ms
Deleting ephemeral... 0ms
Deleting ephemeral... 0ms
Deleting ephemeral... 0ms
Deleting .flutter-plugins-dependencies... 0ms
Deleting .flutter-plugins... 0ms
$ ls .dart_tool
ls: cannot access '.dart_tool': No such file or directory
$ flutter pub get
Running "flutter pub get" in simple_project... 1,487ms
$ cat .dart_tool/dartpad/web_plugin_registrant.dart
// Flutter web plugin registrant file.
//
// Generated file. Do not edit.
//
// ignore_for_file: type=lint
import 'package:cloud_firestore_web/cloud_firestore_web.dart';
import 'package:firebase_analytics_web/firebase_analytics_web.dart';
import 'package:firebase_auth_web/firebase_auth_web.dart';
import 'package:firebase_core_web/firebase_core_web.dart';
import 'package:firebase_database_web/firebase_database_web.dart';
import 'package:firebase_messaging_web/firebase_messaging_web.dart';
import 'package:firebase_storage_web/firebase_storage_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
void registerPlugins([final Registrar? pluginRegistrar]) {
final Registrar registrar = pluginRegistrar ?? webPluginRegistrar;
FirebaseFirestoreWeb.registerWith(registrar);
FirebaseAnalyticsWeb.registerWith(registrar);
FirebaseAuthWeb.registerWith(registrar);
FirebaseCoreWeb.registerWith(registrar);
FirebaseDatabaseWeb.registerWith(registrar);
FirebaseMessagingWeb.registerWith(registrar);
FirebaseStorageWeb.registerWith(registrar);
registrar.registerMessageHandler();
}😰 |
|
@domesticmouse finally found the bit that determines if a project needs web support or not: flutter/packages/flutter_tools/lib/src/project.dart Lines 719 to 724 in ae3e434
The tool checks that |
The
plugin_registrant.dartfor web used to be created onflutter pub get. This was changed to be created only upon build/run time, so the file didn't have to live in the users' working copy (and didn't need to be analyzed alongside user code), here.Making the
plugin_registrant.dartephemeral, however, broke the way that Dartpad compiles Flutter web apps quickly. Read more.This PR adds a
web_plugin_registrant.dartfile in a known location (.dart_tool/dartpad/) atflutter pub getthat Dartpad can use when bootstrapping their code.The file is always generated, regardless of the app using web plugins or not. The contents are the same as for any Flutter web app.
Without plugins:
With a bunch of plugins:
Issues
Tests
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.