Skip to content
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

set packageConfigPath and update DWDS version to 24.3.5 #2589

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 3.7.1-wip
## 3.7.1
- Update `dwds` constraint to `24.3.5`.
- Added a utility method to locate `package_config.json` and set it in the `loadStrategy`.

## 3.7.0

Expand Down
23 changes: 23 additions & 0 deletions webdev/lib/src/serve/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,26 @@ Future<void> _removeDeleted(String from, String to) async {
}
}
}

/// Returns the absolute file path of the `package_config.json` file in the `.dart_tool`
/// directory, searching recursively from the current directory hierarchy.
String? findPackageConfigFilePath() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we compute this if the user didn't pass it into the FrontendServerStrategyProvider, but I do like the idea of being explicit in what webdev passes here and have it "own" the path.

Copy link
Contributor Author

@jyameo jyameo Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that was my thought as well. Thanks @srujzs

var candidateDir = Directory(p.current).absolute;

while (true) {
final candidatePackageConfigFile =
File(p.join(candidateDir.path, '.dart_tool', 'package_config.json'));

if (candidatePackageConfigFile.existsSync()) {
return candidatePackageConfigFile.path;
}

final parentDir = candidateDir.parent;
if (parentDir.path == candidateDir.path) {
// We've reached the root directory
return null;
}

candidateDir = parentDir;
}
}
2 changes: 2 additions & 0 deletions webdev/lib/src/serve/webdev_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '../command/configuration.dart';
import '../util.dart';
import 'chrome.dart';
import 'handlers/favicon_handler.dart';
import 'utils.dart' show findPackageConfigFilePath;

Logger _logger = Logger('WebDevServer');

Expand Down Expand Up @@ -141,6 +142,7 @@ class WebDevServer {
options.configuration.reload,
assetReader,
buildSettings,
packageConfigPath: findPackageConfigFilePath(),
).strategy;

if (options.configuration.enableExpressionEvaluation) {
Expand Down
2 changes: 1 addition & 1 deletion webdev/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webdev/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: webdev
# Every time this changes you need to run `dart run build_runner build`.
version: 3.7.1-wip
version: 3.7.1
# We should not depend on a dev SDK before publishing.
# publish_to: none
description: >-
Expand All @@ -19,7 +19,7 @@ dependencies:
crypto: ^3.0.2
dds: ^4.1.0
# Pin DWDS to avoid dependency conflicts with vm_service:
dwds: 24.2.0
dwds: 24.3.5
http: ^1.0.0
http_multi_server: ^3.2.0
io: ^1.0.3
Expand Down
Loading