Open MichaelFenwick opened 2 months ago
You may want to upvote issue #649.
This is effectively asking for less than #649, that the URI package:foo
is accepted and treated as equivalent to (or normalized to) package:foo/foo.dart
.
It's not impossible. It requires adding a normalization step to package
URI parsing, which adds the /foo.dart
, but it should be well defined how to do that.
As in #649, a package:foo.bar.baz
would normalize to package:foo.bar.baz/baz.dart
, to support existing, and hypothetical future, uses of dotted package names.
I want to normalize the URI rather than having two different URIs denote the same file, because Dart library identity is defined by URI equality. Alternatively we change the rules for library identity to allow equivalences on URIs, so the compiler gets to decide when two URIs are equivalent (within reason).
In Dart, it's extremely common to see imports that look like this
The repetition in there should be plain to see. As it is the case that it's standard for libraries to put the primarily intended import in a file with the same name as the package, I suggest adding syntactic sugar where
import 'package:foo'
would be treated the same asimport 'package:foo/foo.dart'
. Under this proposed change, the current syntax would remain valid.With this feature, the example above would instead look like
Beyond being less typing and less reading, and generally looking cleaner, I believe this sugar would also make it easier to see at a glance which packages are being imported partially. It would also allow these "standard" package imports to better mirror the format of Dart SDK imports (
import 'dart:async;'
).