-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand readable assets for non-root packages, make them configurable #2851
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will take a longer look on Monday, nothing major stands out though.
I think the TargetGraph is the correct place to manage this - that manages what the actual visible individual files are for the package already effectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a problem with the new approach and placeholder nodes like test/$test$
that are added to every package.
When we call runBuilder
here, we don't set the rootPackage
argument. This causes the BuildStepImpl
to believe that the primary input is in fact the root package. Is this a bug? I'm getting test failures when a TestBuilder
(applied to multiple packages) calls canRead('nonRootPackage|test/$test$')
, which is now considered an invalid input.
So what do we do to fix this? I've considered
- disabling the check on placeholder nodes since they can't be read anyways
- Not running a builder on primary inputs that are now invalid
- Making
test/$test$
public by default
To me, option 2 sounds the most reasonable, but it might be considered breaking since builders applied to all packages would no longer run for some placeholder assets. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a problem with the new approach and placeholder nodes like
test/$test$
that are added to every package.
When we callrunBuilder
here, we don't set therootPackage
argument. This causes theBuildStepImpl
to believe that the primary input is in fact the root package. Is this a bug? I'm getting test failures when aTestBuilder
(applied to multiple packages) callscanRead('nonRootPackage|test/$test$')
, which is now considered an invalid input.So what do we do to fix this? I've considered
- disabling the check on placeholder nodes since they can't be read anyways
- Not running a builder on primary inputs that are now invalid
- Making
test/$test$
public by defaultTo me, option 2 sounds the most reasonable, but it might be considered breaking since builders applied to all packages would no longer run for some placeholder assets. What do you think?
I am not quite fully understanding the issue here - it does seem like a bug that we are not passing the rootPackage
argument through though. Does doing that fix the problem?
build/CHANGELOG.md
Outdated
@@ -1,3 +1,9 @@ | |||
## 1.6.0-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumping this to 1.6.0
means many other packages have to be republished as well - and the last time I tried to do that I ran into a lot of issues (it is difficult to validate version solves and things with so many intertwined deps).
I am not sure I would have time to go through this whole process again soon I already lost several days of time to the 1.5.x release :(.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unfortunate but understandable. I changed the version to 1.5.1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I wanted to confirm here - if people get this latest version of build
but not the latest build_runner_core
(which would now be possible) - they will still get an exception when trying to read files outside of lib right? It would just be an AssetNotFoundException
instead of an InvalidInputException
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly. In the old build_runner_core
version, the non-lib files aren't considered by the AssetTracker
at all. So one would definitely get an AssetNotFoundException
.
I do, unfortunately it is internal only. I can fix it up before we merge. |
Consider this test for example. We'd invoke the If we only passed the I brought this up because I'm not sure if we want to consider this a bugfix or a breaking change. Passing the |
Ah - I think the issue here then is that |
Ya we definitely wouldn't want this behavior. |
Note that
My initial statement was inaccurate, we actually pass |
Oh interesting, I don't think this behavior was intentional - cc @natebosch can you think of why that would have been intentional?
I am a bit confused about this part, where do you see this code?
Yes it sounds to me like the |
Sorry for being unclear, I was talking about usages of build/build/lib/src/builder/build_step_impl.dart Lines 109 to 114 in e7b3d4e
However, |
Ok, I understand now :). I agree with your assessment as well, and I don't see any direct instantiations of We should similarly deprecate the argument on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to look pretty close, I want to do another pass before we merge, which I will try to do today. I am on vacation next week though - so either I would need @natebosch to finalize the landing/publishing of this or I can pick it back up on/after 10/19 when I am back.
Speaking of, @natebosch did you want to do a review here as well?
/// | ||
/// This is also the default list of files for targets in non-root packages when | ||
/// an explicit include is not provided. | ||
const List<String> defaultNonRootVisibleAssets = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natebosch particularly it might be good to get another set of eyes here - this list seems pretty reasonable to me though.
Possibly we should add 'CHANGELOG*'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list looks fine to me. I'd be in favor of adding CHANGELOG*
Hey, sorry I just saw this one is still pending. Are you waiting on anything from us? Just a final review or did you have any more work pending here? |
I just fixed the conflicts, so now I don't have any pending work here :) |
I can't think of any reason we'd want |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me. I'm also running this through some internal tests to see if there is anything breaking that we didn't intend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal tests look good.
It looks like one failing test here and then we can merge/publish (possibly update the changelog as Nate suggests as well) |
Instead of throwing an
InvalidInputException
for non-lib, non-root packages, we now allow the following files by default:lib/**
bin/**
LICENSE
README*
pubspec.yaml
Each package can expose additional globs with the
additional_public_assets
build option. I opted to not support exluding assets becauselib/
might lead to unexpected behavioradditional_public_assets
by default. If there were twoexcludes
, it's not clear in which priority they should interfere with each otherIn the root package, all files are still allowed of course. I moved the check to throw an
InvalidInputException
down to theSingleStepReader
. Computing the globs of available sources per package now happens in theTargetGraph
since that's where the build config is read. That feels a bit unclean since the target graph now decides which assets are visible for a package, please let me know if I should move that logic to thePackageGraph
or elsewhere.Closes #2819. I also wrote an example to crawl licenses across dependencies.