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

Support for resolving package config and pubspec.lock in workspaces #3684

Merged
merged 8 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions build_runner/lib/src/build_script_generate/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Future<int> _createKernelIfNeeded(
'lib/_internal/vm_platform_strong.dill',
enabledExperiments: experiments,
printIncrementalDependencies: false,
packagesJson: (await Isolate.packageConfig)!.toFilePath(),
);

var hadOutput = false;
Expand Down
23 changes: 20 additions & 3 deletions build_runner_core/lib/src/package_graph/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,31 @@ class PackageGraph {
'pubspec.yaml.');
}

final packageConfig =
await findPackageConfig(Directory(packagePath), recurse: false);
// The path of the directory that contains .dart_tool/package_config.json.
jakemac53 marked this conversation as resolved.
Show resolved Hide resolved
//
// Should also contain `pubspec.lock`.
var rootDir = packagePath;
PackageConfig? packageConfig;
while (true) {
final packageConfigCandidate =
File(p.join(rootDir, '.dart_tool', 'package_config.json'));
if (packageConfigCandidate.existsSync()) {
packageConfig = await loadPackageConfig(packageConfigCandidate);
break;
}
final next = p.dirname(rootDir);
if (next == rootDir) {
break;
}
rootDir = next;
}

if (packageConfig == null) {
throw StateError(
'Unable to find package config for package at $packagePath.');
}

final dependencyTypes = _parseDependencyTypes(packagePath);
final dependencyTypes = _parseDependencyTypes(rootDir);

final nodes = <String, PackageNode>{};
// A consistent package order _should_ mean a consistent order of build
Expand Down
Loading