Skip to content

Commit 718c39c

Browse files
authored
set packageConfigPath and update DWDS version to 24.3.5 (#2589)
1 parent 4246bbc commit 718c39c

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

webdev/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## 3.7.1-wip
1+
## 3.7.1
2+
- Update `dwds` constraint to `24.3.5`.
3+
- Added a utility method to locate `package_config.json` and set it in the `loadStrategy`.
24

35
## 3.7.0
46

webdev/lib/src/serve/utils.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,26 @@ Future<void> _removeDeleted(String from, String to) async {
8282
}
8383
}
8484
}
85+
86+
/// Returns the absolute file path of the `package_config.json` file in the `.dart_tool`
87+
/// directory, searching recursively from the current directory hierarchy.
88+
String? findPackageConfigFilePath() {
89+
var candidateDir = Directory(p.current).absolute;
90+
91+
while (true) {
92+
final candidatePackageConfigFile =
93+
File(p.join(candidateDir.path, '.dart_tool', 'package_config.json'));
94+
95+
if (candidatePackageConfigFile.existsSync()) {
96+
return candidatePackageConfigFile.path;
97+
}
98+
99+
final parentDir = candidateDir.parent;
100+
if (parentDir.path == candidateDir.path) {
101+
// We've reached the root directory
102+
return null;
103+
}
104+
105+
candidateDir = parentDir;
106+
}
107+
}

webdev/lib/src/serve/webdev_server.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import '../command/configuration.dart';
2121
import '../util.dart';
2222
import 'chrome.dart';
2323
import 'handlers/favicon_handler.dart';
24+
import 'utils.dart' show findPackageConfigFilePath;
2425

2526
Logger _logger = Logger('WebDevServer');
2627

@@ -141,6 +142,7 @@ class WebDevServer {
141142
options.configuration.reload,
142143
assetReader,
143144
buildSettings,
145+
packageConfigPath: findPackageConfigFilePath(),
144146
).strategy;
145147

146148
if (options.configuration.enableExpressionEvaluation) {

webdev/lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webdev/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: webdev
22
# Every time this changes you need to run `dart run build_runner build`.
3-
version: 3.7.1-wip
3+
version: 3.7.1
44
# We should not depend on a dev SDK before publishing.
55
# publish_to: none
66
description: >-
@@ -19,7 +19,7 @@ dependencies:
1919
crypto: ^3.0.2
2020
dds: ^4.1.0
2121
# Pin DWDS to avoid dependency conflicts with vm_service:
22-
dwds: 24.2.0
22+
dwds: 24.3.5
2323
http: ^1.0.0
2424
http_multi_server: ^3.2.0
2525
io: ^1.0.3

0 commit comments

Comments
 (0)