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

Cannot build web app with pure Dart #641

Closed
kaboc opened this issue Sep 23, 2023 · 4 comments · Fixed by #653
Closed

Cannot build web app with pure Dart #641

kaboc opened this issue Sep 23, 2023 · 4 comments · Fixed by #653
Labels
bug Something isn't working

Comments

@kaboc
Copy link
Contributor

kaboc commented Sep 23, 2023

Describe the bug

Building a web app not using Flutter fails due to the universal_io package that is currently lacking support for web.

To Reproduce

Steps to reproduce the behavior:

  1. Create a project with dart create -t web.
  2. Run dart pub add supabase and dart pub get to start using the supabase package.
  3. Prepare to use Supabase by calling the SupabaseClient constructor.
  4. Run the app by webdev serve.
  5. See the warnings printed in the console.
  6. Open localhost:8080 in a browser.

main.dart should look like this:

import 'dart:html';

import 'package:supabase/supabase.dart';

void main() {
  SupabaseClient(
    'Your Supabase URL',
    'Your Supabase Key',
  );

  querySelector('#output')?.text = 'Your Dart app is running.';
}

Expected behavior

There is no warning during a build, and "Your Dart app is running." is shown in the browser.

Screenshots

N/A

Version (please complete the following information):

└── supabase 1.11.5
    ├── functions_client 1.3.2
    ├── gotrue 1.12.2
    ├── postgrest 1.5.1
    ├── realtime_client 1.2.2
    ├── storage_client 1.5.2

Additional context

[WARNING] build_web_compilers:entrypoint on web/main.dart: Skipping compiling bug|web/main.dart with ddc because some of its
transitive libraries have sdk dependencies that not supported on this platform:

universal_io|lib/src/_exports_in_vm.dart
universal_io|lib/src/internet_address.dart
universal_io|lib/src/http_client.dart
@kaboc kaboc added the bug Something isn't working label Sep 23, 2023
@kaboc
Copy link
Contributor Author

kaboc commented Sep 23, 2023

How about removing the dependency on universal_io if it is not heavily used? It will make the supabase package less subject to external changes.

As far as I see,

  • gotrue uses SocketException
  • storage_client uses SocketException and File

It may be possible to replace File with XFile.

@kaboc
Copy link
Contributor Author

kaboc commented Sep 23, 2023

Related issue: dint-dev/universal_io#41

@Vinzent03
Copy link
Collaborator

I'm unsure on how to replace the SocketException. Does everything work except that warning?

@kaboc
Copy link
Contributor Author

kaboc commented Sep 27, 2023

Does everything work except that warning?

main.dart.js is not created due to the dependency on universal_io. I cannot start the web app at all. If you have to see what actually happens, please try building an app, following the steps I wrote earlier.

I was thinking SocketException was reimplementation in universal_io. However, having looked at the source code, it looks like the SocketException itself from dart:io via universal_io if I'm not wrong. It means the package depends on dart:io, whether the app is for mobile / desktop or for web. It seems like the cause of the issue.

I was able to build my blog site made with Dart + Jaspr + Supabase when I was using supabase 1.4.0. I'm not sure about other versions between that version and the latest. Investigating how universal_io was handling SocketException in the past would probably be a way to find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants