Skip to content

Commit 88b25b9

Browse files
authored
Remove --use-polling-watcher flag. (#4133)
1 parent d2be65b commit 88b25b9

File tree

8 files changed

+20
-65
lines changed

8 files changed

+20
-65
lines changed

build_runner/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
for more information.
88
- Remove interactive prompts for whether to delete files.
99
- Ignore `-d` flag: always delete files as if `-d` was passed.
10+
- Remove `--use-polling-watcher` flag.
1011
- Documentation revamp.
1112
- Bug fix: delete transitive generated outputs as well as direct generated
1213
outputs. So, a generated file now gets deleted if its input was a generated

build_runner/lib/src/daemon/daemon_builder.dart

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,28 +274,22 @@ class BuildRunnerDaemonBuilder implements DaemonBuilder {
274274
);
275275

276276
// Only actually used for the AutoChangeProvider.
277-
Stream<List<WatchEvent>> graphEvents() => PackageGraphWatcher(
278-
packageGraph,
279-
watch:
280-
(node) => PackageNodeWatcher(
281-
node,
282-
watch: daemonOptions.directoryWatcherFactory,
277+
Stream<List<WatchEvent>> graphEvents() =>
278+
PackageGraphWatcher(packageGraph, watch: PackageNodeWatcher.new)
279+
.watch()
280+
.asyncWhere(
281+
(change) => shouldProcess(
282+
change,
283+
buildSeries.assetGraph,
284+
buildOptions,
285+
// Assume we will create an outputDir.
286+
true,
287+
expectedDeletes,
288+
environment.reader,
283289
),
284-
)
285-
.watch()
286-
.asyncWhere(
287-
(change) => shouldProcess(
288-
change,
289-
buildSeries.assetGraph,
290-
buildOptions,
291-
// Assume we will create an outputDir.
292-
true,
293-
expectedDeletes,
294-
environment.reader,
295-
),
296-
)
297-
.map((data) => WatchEvent(data.type, '${data.id}'))
298-
.debounceBuffer(buildOptions.debounceDelay);
290+
)
291+
.map((data) => WatchEvent(data.type, '${data.id}'))
292+
.debounceBuffer(buildOptions.debounceDelay);
299293

300294
var changeProvider =
301295
daemonOptions.buildMode == BuildMode.Auto

build_runner/lib/src/entrypoint/options.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import 'package:build_config/build_config.dart';
1111
import 'package:build_daemon/constants.dart';
1212
import 'package:build_runner_core/build_runner_core.dart';
1313
import 'package:path/path.dart' as p;
14-
import 'package:watcher/watcher.dart';
15-
16-
import '../generate/directory_watcher_factory.dart';
1714

1815
const buildFilterOption = 'build-filter';
1916
const configOption = 'config';
@@ -31,7 +28,6 @@ const releaseOption = 'release';
3128
const trackPerformanceOption = 'track-performance';
3229
const skipBuildScriptCheckOption = 'skip-build-script-check';
3330
const symlinkOption = 'symlink';
34-
const usePollingWatcherOption = 'use-polling-watcher';
3531
const verboseOption = 'verbose';
3632

3733
enum BuildUpdatesOption { none, liveReload }
@@ -141,7 +137,6 @@ class DaemonOptions extends WatchOptions {
141137
required super.builderConfigOverrides,
142138
required super.isReleaseBuild,
143139
required super.logPerformanceDir,
144-
required super.usePollingWatcher,
145140
required super.enableExperiments,
146141
}) : super._();
147142

@@ -187,22 +182,13 @@ class DaemonOptions extends WatchOptions {
187182
),
188183
isReleaseBuild: argResults[releaseOption] as bool,
189184
logPerformanceDir: argResults[logPerformanceOption] as String?,
190-
usePollingWatcher: argResults[usePollingWatcherOption] as bool,
191185
enableExperiments: argResults[enableExperimentOption] as List<String>,
192186
);
193187
}
194188
}
195189

196190
class WatchOptions extends SharedOptions {
197-
final bool usePollingWatcher;
198-
199-
DirectoryWatcher Function(String) get directoryWatcherFactory =>
200-
usePollingWatcher
201-
? pollingDirectoryWatcherFactory
202-
: defaultDirectoryWatcherFactory;
203-
204191
WatchOptions._({
205-
required this.usePollingWatcher,
206192
required super.buildFilters,
207193
required super.enableLowResourcesMode,
208194
required super.configKey,
@@ -240,7 +226,6 @@ class WatchOptions extends SharedOptions {
240226
),
241227
isReleaseBuild: argResults[releaseOption] as bool,
242228
logPerformanceDir: argResults[logPerformanceOption] as String?,
243-
usePollingWatcher: argResults[usePollingWatcherOption] as bool,
244229
enableExperiments: argResults[enableExperimentOption] as List<String>,
245230
);
246231
}
@@ -268,7 +253,6 @@ class ServeOptions extends WatchOptions {
268253
required super.builderConfigOverrides,
269254
required super.isReleaseBuild,
270255
required super.logPerformanceDir,
271-
required super.usePollingWatcher,
272256
required super.enableExperiments,
273257
}) : super._();
274258

@@ -349,7 +333,6 @@ class ServeOptions extends WatchOptions {
349333
),
350334
isReleaseBuild: argResults[releaseOption] as bool,
351335
logPerformanceDir: argResults[logPerformanceOption] as String?,
352-
usePollingWatcher: argResults[usePollingWatcherOption] as bool,
353336
enableExperiments: argResults[enableExperimentOption] as List<String>,
354337
);
355338
}

build_runner/lib/src/entrypoint/serve.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class ServeCommand extends WatchCommand {
115115
builderConfigOverrides: options.builderConfigOverrides,
116116
isReleaseBuild: options.isReleaseBuild,
117117
logPerformanceDir: options.logPerformanceDir,
118-
directoryWatcherFactory: options.directoryWatcherFactory,
119118
buildFilters: options.buildFilters,
120119
);
121120

build_runner/lib/src/entrypoint/watch.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ class WatchCommand extends BuildRunnerCommand {
2727
'Builds the specified targets, watching the file system for updates and '
2828
'rebuilding as appropriate.';
2929

30-
WatchCommand() {
31-
argParser.addFlag(
32-
usePollingWatcherOption,
33-
help:
34-
'Use a polling watcher instead of the current platforms default '
35-
'watcher implementation. This should generally only be used if '
36-
'you are having problems with the default watcher, as it is '
37-
'generally less efficient.',
38-
);
39-
}
40-
4130
@override
4231
WatchOptions readOptions() => WatchOptions.fromParsedArgs(
4332
argResults!,
@@ -73,7 +62,6 @@ class WatchCommand extends BuildRunnerCommand {
7362
builderConfigOverrides: options.builderConfigOverrides,
7463
isReleaseBuild: options.isReleaseBuild,
7564
logPerformanceDir: options.logPerformanceDir,
76-
directoryWatcherFactory: options.directoryWatcherFactory,
7765
buildFilters: options.buildFilters,
7866
);
7967

build_runner/lib/src/generate/build.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:build/build.dart';
99
import 'package:build_runner_core/build_runner_core.dart';
1010
import 'package:logging/logging.dart';
1111
import 'package:shelf/shelf.dart';
12-
import 'package:watcher/watcher.dart';
1312

1413
import '../package_graph/build_config_overrides.dart';
1514
import '../server/server.dart';
@@ -136,9 +135,6 @@ Future<BuildResult> build(
136135
/// keep changing with less than that amount of time apart, builds will be put
137136
/// off.
138137
///
139-
/// The [directoryWatcherFactory] allows you to inject a way of creating custom
140-
/// `DirectoryWatcher`s. By default a normal `DirectoryWatcher` will be used.
141-
///
142138
/// The [terminateEventStream] is a stream which can send termination events.
143139
/// By default the [ProcessSignal.sigint] stream is used. In this mode, the
144140
/// first event will allow any ongoing builds to finish, and then the program
@@ -156,7 +152,6 @@ Future<ServeHandler> watch(
156152
Level? logLevel,
157153
void Function(LogRecord)? onLog,
158154
Duration? debounceDelay,
159-
required DirectoryWatcher Function(String) directoryWatcherFactory,
160155
Stream<ProcessSignal>? terminateEventStream,
161156
bool? enableLowResourcesMode,
162157
Set<BuildDirectory>? buildDirs,
@@ -177,7 +172,6 @@ Future<ServeHandler> watch(
177172
resolvers: resolvers,
178173
onLog: onLog,
179174
debounceDelay: debounceDelay,
180-
directoryWatcherFactory: directoryWatcherFactory,
181175
terminateEventStream: terminateEventStream,
182176
enableLowResourcesMode: enableLowResourcesMode,
183177
buildDirs: buildDirs,

build_runner/lib/src/generate/watch_impl.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Future<ServeHandler> watch(
3838
Resolvers? resolvers,
3939
void Function(LogRecord)? onLog,
4040
Duration? debounceDelay,
41-
required DirectoryWatcher Function(String) directoryWatcherFactory,
41+
DirectoryWatcher Function(String)? directoryWatcherFactory,
4242
Stream<ProcessSignal>? terminateEventStream,
4343
bool? skipBuildScriptCheck,
4444
bool? enableLowResourcesMode,
@@ -129,7 +129,7 @@ WatchImpl _runWatch(
129129
List<BuilderApplication> builders,
130130
Map<String, Map<String, dynamic>> builderConfigOverrides,
131131
Future until,
132-
DirectoryWatcher Function(String) directoryWatcherFactory,
132+
DirectoryWatcher Function(String)? directoryWatcherFactory,
133133
String? configKey,
134134
bool willCreateOutputDirs,
135135
Set<BuildDirectory> buildDirs,
@@ -160,7 +160,7 @@ class WatchImpl implements BuildState {
160160
final Duration _debounceDelay;
161161

162162
/// Injectable factory for creating directory watchers.
163-
final DirectoryWatcher Function(String) _directoryWatcherFactory;
163+
final DirectoryWatcher Function(String)? _directoryWatcherFactory;
164164

165165
/// Whether or not we will be creating any output directories.
166166
///

build_runner/lib/src/watcher/graph_watcher.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ class PackageGraphWatcher {
5454
) {
5555
buildLog.error(
5656
buildLog.renderThrowable(
57-
'Error from directory watcher for '
58-
'package:${w.node.name}\n\n'
59-
'If you see this consistently then it is recommended that '
60-
'you enable the polling file watcher with '
61-
'--use-polling-watcher.',
57+
'Failed to watch files in package:${w.node.name}.',
6258
e,
6359
),
6460
);

0 commit comments

Comments
 (0)