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

Web issues #58

Closed
busslina opened this issue Feb 4, 2024 · 1 comment
Closed

Web issues #58

busslina opened this issue Feb 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@busslina
Copy link

busslina commented Feb 4, 2024

When transpiling for Dart Web I got this warning, which is fatal because it breaks the transpile:

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

logger|lib/src/outputs/file_output_stub.dart

https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings

I tried to bypass it by replacing this:

import 'package:logger/logger.dart'

into this:

import 'package:logger/src/logger.dart';
import 'package:logger/src/filters/production_filter.dart';
import 'package:logger/src/outputs/console_output.dart';
import 'package:logger/src/printers/simple_printer.dart';
import 'package:logger/src/log_level.dart';

which leads to these static warnings (non-fatal), but the fatal warning still not solved:

Import of a library in the 'lib/src' directory of another package.
Try importing a public library that exports this library, or removing the import

Firstly I want to solve the fatal warning: Is there a way to import in a web safe way?

Secondly, would be great that the first solution also removes the non fatal warnings.

Thanks

@busslina busslina mentioned this issue Feb 4, 2024
@Bungeefan
Copy link
Member

Hi, what a bummer...
Sorry, this took me some time to research and understand your use-case and investigate possible solutions.

It seems that there are only two viable options for Dart Web projects:

  • Modify the build.yaml to change the web_compiler strategy to fine, as described here (I have successfully tested this myself, however I am not sure whether this configuration has any other side effects, so use with care!)
  • Remove the stub from the exports, or in other words, make a web-only export library (as in your PR).

I also tried modifying the stub to circumvent the pointless warning, but without using dynamic as type it seems to be impossible to satisfy the web compiler (using dynamic would also render the stub effectively impractical).

Interesting sidenote: The reason why this problem "only" exists in Dart and not in Flutter is because they made an (originally temporary) exception for Flutter Web. Source: dart-lang/build#3614 (comment)

@Bungeefan Bungeefan added the bug Something isn't working label Feb 26, 2024
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

No branches or pull requests

2 participants