-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Flutter Web Bootstrapping Improvements #144434
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
Flutter Web Bootstrapping Improvements #144434
Conversation
ditman
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.
Man, this looks GREAT. I'm updating one of my test apps to use this, see how it goes!
Co-authored-by: David Iglesias <[email protected]>
ditman
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.
I have been testing this, and it's great. I wonder if the flutter_bootstrap.js file could be minified!
Also, somewhat unrelated to this PR (but IMO relevant for the feature); it'd be nice to have more feedback when the flutter bootstrap falls-back to JS, why.
Right now I have an application deployed that I'd expect to see in --wasm, but it's falling back to JS (in a supposedly supported browser), and I don't know why!
| return stripLeadingSlash(stripTrailingSlash(baseHref)); | ||
| } | ||
|
|
||
| List<WebTemplateWarning> getWarnings() { |
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.
Not sure if possible, but it'd be nice that these warnings were also emitted on flutter run.
_Description of what this PR is changing or adding, and why:_ Update Wasm getting started instructions to: - Simplify a bit - Rely on the standard template to ensure they are compatible - Align with bootstrap changes landed in flutter/flutter#144434 ## Presubmit checklist - [ ] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [ ] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [ ] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
_Description of what this PR is changing or adding, and why:_ Update Wasm getting started instructions to: - Simplify a bit - Rely on the standard template to ensure they are compatible - Align with bootstrap changes landed in flutter/flutter#144434 ## Presubmit checklist - [ ] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [ ] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [ ] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
This updates the documentation to be in line with the new changes to bootstrapping that are coming in this PR: flutter/flutter#144434 --------- Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]>
This makes several changes to flutter web app bootstrapping.
flutter_bootstrap.jsfile.flutter_bootstrap.jsfile in thewebsubdirectory in the project directory which can have whatever custom bootstrapping logic they'd like to write instead. This file is also templated, and can use any of the tokens that can be used with theindex.html(with the exception of{{flutter_bootstrap_js}}, see below).index.html:{{flutter_js}}=> inlines the entirety offlutter.js{{flutter_service_worker_version}}=> replaced directly by the service worker version. This can be used instead of the script that sets theserviceWorkerVersionlocal variable that we used to have by default.{{flutter_bootstrap_js}}=> inlines the entirety offlutter_bootstrap.js(this token obviously doesn't apply toflutter_bootstrap.jsitself).IndexHtmlto be calledWebTemplateinstead, since it is used for more than just the index.html now.(const|var) serviceWorkerVersion = null) and recommends using{{flutter_service_worker_version}}token insteadFlutterLoader.loadEntrypointand recommend usingFlutterLoader.loadinsteadflutter_service_worker.js.index.htmlonflutter createnow uses an async script tag withflutter_bootstrap.js.