Skip to content

Users are confused what unit(s) of Dart are signficant #34135

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matanlurey opened this issue Aug 13, 2018 · 3 comments
Closed

Users are confused what unit(s) of Dart are signficant #34135

matanlurey opened this issue Aug 13, 2018 · 3 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-stale Closed as the issue or PR is assumed stale core-l customer-google3 type-enhancement A request for a change that isn't a bug

Comments

@matanlurey
Copy link
Contributor

matanlurey commented Aug 13, 2018

Forked from the discussion in dart-lang/language#11.

We have, 6, maybe 7 different ways of expressing a "unit of Dart code" as-of Dart 2.0:

  • Files (i.e. on disk, a file.dart), until Recognize file entry-points that should be accessed as package URIs #33076 is fixed?
    • Package files (i.e. loaded via package:name/file.dart and .packages spec)
  • Libraries (i.e. a file with optionally 1 or more part files contributing to it)
  • Packages (i.e. package:name with a pubspec.yaml file and lib/ folder)
    • Tests (i.e. the test/ folder of a package)
  • Bazel Targets (with some overlap with package, but other differences - such as subset of sources and dependencies where-as packages encapsulate all files in lib/ and the union of all of their dependencies). I imagine this also overlaps with GN/Ninja for the SDK and Fuischa to some extent.
  • Build Modules (i.e. how build_runner determines incremental builds for DDC and the VM/Kernel)

... some of these units are only understood by certain tools:

Tool File Libraries Packages Tests Targets Modules
Analyzer
package:meta
package:linter
DDC
Dart2JS
Dart VM ✅ ☆
CFE
package:build
Bazel Rules

⚠️See #33076 for how the VM differs from other tools in this regard

This had made it exceedingly difficult to:

  • Help inform users the best way to structure code for faster incremental compile
  • Help inform users the best way to structure code to avoid extraneous dependencies
  • Help build tools that perform modular analysis and computation in a uniform way
  • Help build tools that return accurate results for all environments
    • For example the analyzer allows importing files that are not visible to a target in Bazel
  • Instruct changes to the language or tools around the concept of visibility across units
    • See sealed, protected, etc

/cc @bwilkerson, @srawlins who are very passionate about this topic.

@srawlins
Copy link
Member

This would be a great soft spot in the underbelly of Dart to firm up with some armor, a la best-practices documentation, allowing the term "package" into the language spec for concepts like visibility, and maybe some language features like "package-private" declarations and "friend" libraries. Further reading:

@lrhn lrhn added the type-enhancement A request for a change that isn't a bug label Aug 14, 2018
@lrhn
Copy link
Member

lrhn commented Aug 14, 2018

There are actually two different notions of packages: Pub packages and language packages.

The one you list (pubspec.yaml and lib dir) is the pub package. The language never sees that, it only sees "the collection of files at the end of a package:packageName/ URI" (the "package files") as a package.
If the language introduces "package" as a concept in the specification, the language package is what it will have to work with, not the pub package.

(You could argue that "language packages" is not really a concept at all, because it has no effect on anything, but at least there is some logic included in the package URI handling).

@a-siva a-siva added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Aug 14, 2018
@matanlurey
Copy link
Contributor Author

@lrhn:

... the language package is what it will have to work with, not the pub package.

Unfortunately, that would what preclude anything that understands the test/ folder, for example.

@matanlurey matanlurey added the P2 A bug or feature request we're likely to work on label Aug 27, 2018
@lrhn lrhn added core-l and removed P2 A bug or feature request we're likely to work on labels Dec 6, 2018
@lrhn lrhn added the closed-stale Closed as the issue or PR is assumed stale label Apr 9, 2025
@lrhn lrhn closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-stale Closed as the issue or PR is assumed stale core-l customer-google3 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants