Skip to content

Commit 9fda354

Browse files
authored
Fix watch mode not building on missingSource creation. (#4017)
1 parent 063e60d commit 9fda354

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

build_runner/test/generate/watch_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,45 @@ void main() {
260260
);
261261
});
262262

263+
test('rebuilds on created missing source files', () async {
264+
final application = applyToRoot(
265+
TestBuilder(
266+
buildExtensions: appendExtension('.copy', from: '.txt'),
267+
extraWork: (buildStep, _) async {
268+
await buildStep.canRead(makeAssetId('a|web/b.other'));
269+
},
270+
),
271+
);
272+
273+
var buildState = await startWatch(
274+
[application],
275+
{'a|web/a.txt': 'a'},
276+
readerWriter,
277+
packageGraph: packageGraph,
278+
);
279+
var results = StreamQueue(buildState.buildResults);
280+
281+
var result = await results.next;
282+
checkBuild(
283+
result,
284+
outputs: {'a|web/a.txt.copy': 'a'},
285+
readerWriter: readerWriter,
286+
);
287+
288+
readerWriter.testing.writeString(makeAssetId('a|web/b.other'), 'b');
289+
FakeWatcher.notifyWatchers(
290+
WatchEvent(ChangeType.ADD, path.absolute('a', 'web', 'b.other')),
291+
);
292+
293+
// Should rebuild due to the previously-missing input appearing.
294+
result = await results.next;
295+
checkBuild(
296+
result,
297+
outputs: {'a|web/a.txt.copy': 'a'},
298+
readerWriter: readerWriter,
299+
);
300+
});
301+
263302
test('rebuilds on deleted files outside hardcoded sources', () async {
264303
var buildState = await startWatch(
265304
[copyABuildApplication],

build_runner_core/lib/src/asset_graph/node.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ abstract class AssetNode implements Built<AssetNode, AssetNodeBuilder> {
100100

101101
/// Whether changes to this node will have any effect on other nodes.
102102
bool get changesRequireRebuild =>
103-
type == NodeType.internal || type == NodeType.glob || digest != null;
103+
type == NodeType.internal ||
104+
type == NodeType.glob ||
105+
type == NodeType.missingSource ||
106+
digest != null;
104107

105108
factory AssetNode([void Function(AssetNodeBuilder) updates]) = _$AssetNode;
106109

0 commit comments

Comments
 (0)