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

Changed Conditional Imports #380

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

AlexBacich
Copy link

@AlexBacich AlexBacich commented Jul 3, 2024

During compiling project to WASM I get these errors:

../../../.pub-cache/hosted/pub.dev/dbus-0.7.10/lib/src/getsid_windows.dart:1:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^
../../../.pub-cache/hosted/pub.dev/dbus-0.7.10/lib/src/getuid_linux.dart:1:1: Error: 'dart:ffi' can't be imported when compiling to Wasm.
import 'dart:ffi';
^

Changing conditional imports to dart.library.io solves the problem.
For example:

export 'getsid_stub.dart' if (dart.library.io) 'getsid_windows.dart';

As a workaround for now this helps:

 dependency_overrides: 
  dbus: # Till the fix for conditional import merged https://github.com/canonical/dbus.dart/pull/380
    git:
      url: https://github.com/AlexBacich/dbus.dart.git
      ref: a01bb05

Copy link

github-actions bot commented Jul 3, 2024

Hey! undefined has not signed the Canonical CLA which is required to get this contribution merged on this project.

Please head over to https://ubuntu.com/legal/contributors to read more about it.

@@ -1,2 +1,2 @@
// Conditionally import the FFI version, so this doesn't break web builds.
export 'getsid_stub.dart' if (dart.library.ffi) 'getsid_windows.dart';
export 'getsid_stub.dart' if (dart.library.io) 'getsid_windows.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

Since both dart:io and dart:ffi are required does this require an ||?

@robert-ancell
Copy link
Contributor

@AlexBacich apologies, this seemed to get missed. Did you sign the CLA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants