dart-archive / barback

An asset build system for Dart.
https://pub.dartlang.org/packages/barback
BSD 3-Clause "New" or "Revised" License
10 stars 9 forks source link

barback: allow source assets at top-level of package #53

Closed DartBot closed 9 years ago

DartBot commented 9 years ago

Issue by seaneagan Originally opened as dart-lang/sdk#19434


I'd like to write a transformer to copy a package's "pubspec.yaml" to a sub-directory (e.g. "lib") that's available when running pub serve/build/run/issue dart-lang/pub#970, but from:

https://www.dartlang.org/tools/pub/assets-and-transformers.html

"An asset can be in any root level directory of your package"

So I assume that means source assets cannot be at the top-level as "pubspec.yaml" is.

Can that restriction be relaxed?

DartBot commented 9 years ago

Comment by kasperl


Added Area-Pkg, Pkg-Barback, Triaged labels.

DartBot commented 9 years ago

Comment by nex3


Unfortunately, this restriction is pretty important. Pub makes a lot of assumptions that the publicly-accessible files in your package are exactly those in lib/. These assumptions are necessary for performance, since listing and loading the contents of every file in every dependency can be extremely painful, and for correctness, since users may not want or expect their transformers to run on files outside lib (or web/ or bin/, if they're using serve, build, and/or run).


Added NotPlanned label.

DartBot commented 9 years ago

Comment by seaneagan


I see there is a $include configuration that can be passed to a transformer in the pubspec. Why not let $include refer to files at the top-level:

transformers:   copy_to_lib:     $include: pubspec.yaml

DartBot commented 9 years ago

Comment by nex3


Although semantically that may work, there are a lot of technological issues. Pub has a lot of logic that assumes a certain set of directories to be relevant, and that filters down to stuff like directory watching and publishing in complex ways.

We do want to find a way to provide packages' versions to the program, but I don't think this is how we'll do it.

DartBot commented 9 years ago

Comment by seaneagan


Here is another use case for accessing top-level files from transformers:

https://github.com/sethladd/dartdoc/issues/2

DartBot commented 9 years ago

Comment by nex3


Issue dart-lang/pub#1191 has been merged into this issue.