Description
Dart has library declarations of the form library some.name;
which are no longer commonly used.
The name used to be required for having part
files, but is now not necessary.
Giving a library a name is only really useful for avoiding duplicate imports with different paths, so most libraries do not use the declaration.
However, it's still useful to have a library declaration for a number of reasons:
- Adding annotations/metadata to the library.
- Writing documentation for the library.
The latter is "fixed" by the dartdoc tool assuming that a dartdoc occurring before the first import is really documenting the library, and not the import. (Edit: No, it actually doesn't. The culprit is the @TestOn
annotation.)
The former is not fixed, so when you want to annotate your library with metadata, you need to give it an otherwise completely useless name.
The obvious solution would be to allow a declaration of the form library;
, which gives the library the empty name (same as no library declaration). It's just a hook to hang your annotations from.
Feature specification
Experiment flag
--unnamed-libraries
Implementation Tasks
- language tests written (https://dart-review.googlesource.com/c/sdk/+/262580).
-
core library updates. - implementation in CFE
(https://dart-review.googlesource.com/c/sdk/+/257490). - implementation in Analyzer
(https://dart-review.googlesource.com/c/sdk/+/257490). - implementation in Dartfmt (Support unnamed libraries dart_style#1141).
- implementation in build systems and Angular compiler.
- support in linter (Support unnamed libraries dart-archive/linter#3730).
- implementation in Dartdoc (Unnamed libraries support dartdoc#3188).
-
implementation in DDC. -
implementation in the VM. - VM Service support.
-
implementation in syntax highlighters -
Github syntax highlighting. -
highlight.js support (api.dart.dev, api.pub.dev, Dartdoc): -
CodeMirror support (DartPad). -
implementation in IntelliJ. -
implementation in Cider. -
web debugging support. -
implementation in dart2js. - implementation in Kythe.
- documentation. - [2.19] Update documentation on Dart library directive to include non-name libraries site-www#4314
Metadata
Metadata
Assignees
Labels
Type
Projects
Status