Skip to content
This repository was archived by the owner on Jul 20, 2018. It is now read-only.

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

Closed
DartBot opened this issue Jun 5, 2015 · 6 comments
Closed

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

DartBot opened this issue Jun 5, 2015 · 6 comments

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="96" height="96"hspace="10"> 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
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/2156198?v=3" align="left" width="48" height="48"hspace="10"> Comment by kasperl


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

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> 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
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="48" height="48"hspace="10"> 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
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> 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
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="48" height="48"hspace="10"> Comment by seaneagan


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

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

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


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

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

No branches or pull requests

2 participants