Skip to content

Allow Pubspec.yaml to supply missing SDK libraries (dart:io, dart:html, etc.) #37232

Open

Description

@terrier989

It would be helpful if something like this was possible:

dependency_overrides:
  "dart:io": universal_io

This would enable use packages like universal_io and universal_html without forking dependencies just to replace imports.

Proposed details:

  • The dependency override would be ignored if the target already supports dart:L.
  • The effect would be equal to replacing imports of dart:L with package:P/L.dart.
  • Behavior of configured imports would not be affected. Condition in if (dart.library.io) 'library.dart' would false in Dart2js even if dart:io was supplied with a dependency override.

Activity

  1. added
    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
    on Jun 11, 2019
  2. devoncarew commented on Jun 11, 2019

    @devoncarew
    Contributor

    I'm not sure where to best file this feature request - tentatively assigning to area-library.

  3. changed the title [-]Support dependency overrides for dart:io and dart:html[/-] [+]Allow Pubspec.yaml to supply missing SDK libraries (dart:io, dart:html, etc.)[/+] on Jun 13, 2019
  4. terrier989 commented on Jun 13, 2019

    @terrier989
    Author

    This feature could provide at least temporary help to Flutter web team, which seems to be thinking about cross-platform issues such as missing dart:io (#35969) and dart:developer (#36649). Angular would get server-side rendering in Dart VM (#225).

    The proposal could be simplified by using prefix "__" for supplying SDK libraries ("__io", "__html", etc.). This feature would be just a preprocessor in the Dart frontend. In pseudo code:

    when the preprocessor sees "import/export dart:L":
      if target SDK doesn't have library "dart:L" and Pub has added "__L:file://path" in ".packages" file:
        replace "dart:L" with "package:__L/L.dart"
    

    With "__libraryName" convention, Pub doesn't need changes. Pub already generates ".packages" file when pubspec.yaml is:

    dependency_overrides:
      # This supplies dart:io to Dart2js
      __io:
        git: "https://github.com/some/repository" # Package name must be "__io"

    You wouldn't be able to use hosted packages (Pub would throw "package names must be equal"), but it can be fixed separately from this feature.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions