Skip to content

Understand conditional imports #2763

Closed
Closed

Description

@simc

My package has a conditional import which either imports a file which uses dart:io (for vm) or another file which uses dart:indexed_db (for web).

The analysis tab on pub.dev says:

Detected platforms: Flutter, other

Primary library: package:hive/hive.dart with components: io.

It should also detect "web". I think there is a problem with detecting the supported platform when conditional imports are used.

Activity

  1. jonasfj commented on Sep 12, 2019

    @jonasfj
    Member

    It should also detect "web". I think there is a problem with detecting the supported platform when conditional imports are used.

    Correct, there is a bug here.

    We are looking into refactoring the platform detection in pana soon, but I'm not sure this will get fixed. For now there is few packages that uses conditional imports, and they have special handling in pana 🙈

    https://github.com/dart-lang/pana/blob/aaa9afa7000a2064678e2339f1d0a3cb4d79b7f3/lib/src/package_analyzer.dart#L264-L269

  2. simc commented on Sep 12, 2019

    @simc
    Author

    Should I open an issue for pana too?

  3. isoos commented on Sep 12, 2019

    @isoos
    Collaborator

    @leisim: in which of your libraries are you using the conditional import? Could you please link to it? Is it reachable from package:hive/hive.dart?

  4. simc commented on Sep 12, 2019

    @simc
    Author

    @isoos
    The library is hive and here is the file with the conditional import. This file is not part of the hive library but it is imported.

  5. isoos commented on Sep 12, 2019

    @isoos
    Collaborator

    This file is not part of the hive library but it is imported.

    As the storage_backend.dart is imported in the main library, I think we should probably adjust the component detection in pana (to also detect these in conditional exports), but with the current logic after that, it will classify them as conflicting components, and the package will be marked as "platform conflict". I think we should keep this issue open, and we'll deal with it as we go ahead with the rewrite/refactoring of the platform classification.

  6. yjbanov commented on Sep 13, 2019

    @yjbanov
  7. jonasfj commented on Aug 4, 2020

    @jonasfj
    Member

    I think this is fixed now, please reopen if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions