flutterfire
flutterfire copied to clipboard
[firebase_core]: Error Encountered After Upgrading Firebase Core to v2.30.1: Invalid Conditional Import in _flutterfire_internals Package
Is there an existing issue for this?
- [X] I have searched the existing issues.
Which plugins are affected?
Core
Which platforms are affected?
No response
Description
After upgrading Firebase Core from version 2.27.0 to version 2.30.1, running the build runner resulted in the following error in the log output.
The error originates from the _flutterfire_internals package v1.3.32. Downgrading the package to v1.3.31 by overriding it, resolved the error. It's noted that the error was addressed in a merged pull request: PR #12698, which was released in version 1.3.32.
Expected Behavior
The build runner should execute without errors.
Current Behavior
The build runner fails with the reported error.
Reproducing the issue
Upgrade Firebase Core to version 2.30.1.
Using the latest build_runner: ^2.4.9
Run the build runner dart run build_runner build --delete-conflicting-outputs
Firebase Core version
2.30.1
Flutter Version
3.19.6
Relevant Log Output
[SEVERE] build_modules:module_library on package:_flutterfire_internals/_flutterfire_internals.dart (cached):
Invalid argument(s): Unsupported conditional import of `dart:js_interop` found in _flutterfire_internals|lib/_flutterfire_internals.dart:
import 'src/interop_shimmer.dart' if (dart.library.js_interop) 'dart:js_interop' as js_interop;
This environment does not support direct conditional imports of `dart:` libraries. Instead you must create a separate library which unconditionally imports (or exports) the `dart:` library that you want to use, and conditionally import (or export) that library.
[SEVERE] Failed after 1m 28s
Flutter dependencies
Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response
Thanks for the report I'm looking into it, have you tried to exclude this particular file in your build.yaml file?
I cannot reproduce the issue, could you give a complete sample?
hello @Lyokone ,
my comment not related to mentioned issue, but if I can please ask to do another version release to include 10.11.1 firebase js library https://firebase.google.com/support/release-notes/js to resolve following issue https://github.com/firebase/firebase-js-sdk/pull/8145 which is long running annoying problem for my flutter app, please help 🙏
Same error here:
Deprecated. Use `dart run` instead.
[INFO] Generating build script completed, took 188ms
[INFO] Setting up file watchers completed, took 4ms
[INFO] Waiting for all file watchers to be ready completed, took 676ms
[INFO] Reading cached asset graph completed, took 876ms
[INFO] Checking for updates since last build completed, took 1.1s
[INFO] Running build completed, took 247ms
[INFO] Caching finalized dependency graph completed, took 898ms
[SEVERE] build_modules:module_library on package:_flutterfire_internals/_flutterfire_internals.dart (cached):
Invalid argument(s): Unsupported conditional import of `dart:js_interop` found in _flutterfire_internals|lib/_flutterfire_internals.dart:
import 'src/interop_shimmer.dart' if (dart.library.js_interop) 'dart:js_interop' as js_interop;
This environment does not support direct conditional imports of `dart:` libraries. Instead you must create a separate library which unconditionally imports (or exports) the `dart:` library that you want to use, and conditionally import (or export) that library.
[SEVERE] Failed after 1.2s
@Lyokone pinning 2.30.0 solves it.
firebase_core: 2.30.0
firebase_messaging: ^14.8.0
I ran into this too. Updating to the latest versions of all the Flutter Firebase packages solved the error for me.
For some reason, updating to the latest Firebase packages worked earlier, but now I'm getting the same error again, even with all the latest packages.
Pinning _flutterfire_internals to 1.3.31 solves the error for me.
Hey @isaacadariku. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
The issue still happen with firebase_core: 2.31.0
@Lyokone Thanks for the response. I have not tried excluding the file in the build.yaml file. Can you provide an example of excluding the file in the build.yaml file? As this file is part of the _flutterfire_internals package, I am not sure how to exclude it.
I will try to create a sample project to reproduce the issue and share it with you.
Thanks, waiting for your sample project @isaacadariku
Hi @isaacadariku, I was running into this issue as well, and have a small workaround which I might submit as a PR if it works for you too. Can you see if that's the case?
dependency_overrides:
_flutterfire_internals:
git:
url: https://github.com/elitree/flutterfire.git
path: packages/_flutterfire_internals
ref: fix-web-build-error
Hi @Lyokone, I'm still not 100% sure how this is happening in my build.yaml, but I believe it has to do with some reference build_web_compilers code from the drift project for using web workers that I'm using in my project. It seems that the dart2js compilation from that reference code doesn't play nicely with the direct dart:js_interop import added in #12698. Based on this other similar issue, I tried using an indirect import for the workaround mentioned above, and that fixed my build error.
I apologize that I'm still not sure how to reproduce the original example, but my guess based on the above is it would involve adding a builder using the build_web_compilers package and dart2js. Thanks
Hi @isaacadariku, I was running into this issue as well, and have a small workaround which I might submit as a PR if it works for you too. Can you see if that's the case?
dependency_overrides: _flutterfire_internals: git: url: https://github.com/elitree/flutterfire.git path: packages/_flutterfire_internals ref: fix-web-build-errorHi @Lyokone, I'm still not 100% sure how this is happening in my build.yaml, but I believe it has to do with some reference
build_web_compilerscode from thedriftproject for using web workers that I'm using in my project. It seems that the dart2js compilation from that reference code doesn't play nicely with the directdart:js_interopimport added in #12698. Based on this other similar issue, I tried using an indirect import for the workaround mentioned above, and that fixed my build error.I apologize that I'm still not sure how to reproduce the original example, but my guess based on the above is it would involve adding a builder using the
build_web_compilerspackage and dart2js. Thanks
@elitree I am also using drift and have a web project. I think you could be on to something there.
Hi @Lyokone, I submitted the above PR to resolve this issue. But I totally understand if you'd rather wait for a minimal reproducible example before looking at the PR, so let me know if that's the case. Thanks.
Hey @isaacadariku. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Quick note that https://github.com/firebase/flutterfire/pull/12925 is submitted to fix this issue. Thanks…
Since there haven't been any recent updates here, I am going to close this issue.
@isaacadariku if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Can we leave this open until #12925 is merged to fix the issue?
A fix from @elitree is almost ready to be merged to fix this. Hey, @google-oss-bot, please re-open the issue 😄
The PR is now merged