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

fix(core): Omit unnecessary libraries for web #10068

Conversation

kaptnkoala
Copy link
Contributor

@kaptnkoala kaptnkoala commented Dec 7, 2022

Description

Currently it seems that unnecessary web libraries are loaded on start of a Flutter Web application.

In our case, we only want to use Firebase Analytics to send tracking data. For this we need to install the firebase_core and firebase_analytics package as dependencies in our project. But when we launch the bundled app in the browser, there are additional JS libraries loaded to the expected firebase-app.js and firebase-analytics.js files. At launch of our app, these JS libraries are loaded.

  • firebase-app.js
  • firebase-analytics.js
  • firebase-app-check.js
  • firebase-remote-config.js
  • firebase-firestore.js

The firebase-firestore.jsdependency comes from the firebase_core and firebase_analytics using shared functionality from _flutterfire_internals, which has the cloud_firestore_platform_interface and cloud_firestore_web packages in its dependencies. But there does not seem to be any code used from these dependencies, so it seems that they could be removed.

The firebase-app-check.js and firebase-remote-config.js libraries are loaded because the app-check and remote-config JS libraries are installed as default web services in FirebaseCoreWeb platform interface. I have not found any explanation in the code, why this is necessary, because both web plugins register their web service on plugin registration, when they are added as discrete dependency to a project.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@kaptnkoala kaptnkoala changed the title Omit unnecessary libraries for web fix(core) Omit unnecessary libraries for web Dec 7, 2022
@kaptnkoala kaptnkoala changed the title fix(core) Omit unnecessary libraries for web fix(core): Omit unnecessary libraries for web Dec 7, 2022
@Lyokone Lyokone self-assigned this Dec 15, 2022
@@ -35,9 +35,6 @@ typedef EnsurePluginInitialized = Future<void> Function()?;
class FirebaseCoreWeb extends FirebasePlatform {
static Map<String, FirebaseWebService> _services = {
'core': FirebaseWebService._('app', override: 'core'),
'app-check': FirebaseWebService._('app-check', override: 'app_check'),
Copy link
Member

Choose a reason for hiding this comment

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

This isn't going to work. We still need to rename those libraries, just not add them as a dependency.

@russellwheatley
Copy link
Member

Hey @kaptnkoala - do you intend to update this PR?

@blaugold blaugold force-pushed the feature/omit-transitive-libraries-for-web branch from 137ea17 to 6642409 Compare June 7, 2023 12:06
@blaugold
Copy link
Contributor

blaugold commented Jun 7, 2023

@russellwheatley I've update the PR so that web plugins that need override the Firebase Web product name, provide the override when registering them selfs. I felt like that is a more natural place to define those overrides, but let me know what you think.

The necessary change in the firebase_web_core API is breaking though.

@russellwheatley
Copy link
Member

Thanks @blaugold! This is exactly what was needed. We don't consider this breaking as it is underlying implementation and not user facing API 😄

@russellwheatley
Copy link
Member

@blaugold - do you mind merging with master? I think it'll fix the Firestore web e2e tests

@blaugold blaugold force-pushed the feature/omit-transitive-libraries-for-web branch from 6642409 to efaf538 Compare June 12, 2023 11:27
@blaugold
Copy link
Contributor

@russellwheatley Thanks for the ping. I think that did it.

@russellwheatley russellwheatley merged commit 8659d4e into firebase:master Jun 12, 2023
18 checks passed
khanliKU pushed a commit to khanliKU/flutterfire that referenced this pull request Jun 18, 2023
Co-authored-by: Gabriel Terwesten <gabriel@terwesten.net>
@firebase firebase locked and limited conversation to collaborators Jul 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants