Skip to content
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: 4 additions & 0 deletions build_modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.1.2

- Make compatible with `dart run build_runner build --force-aot`.

## 5.1.1

- Fix re-add `multiRootScheme` to build_modules exports.
Expand Down
25 changes: 24 additions & 1 deletion build_modules/lib/src/scratch_space.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final scratchSpaceResource = Resource<ScratchSpace>(
p.join(scratchSpace.tempDir.path, '.dart_tool', 'package_config.json'),
);
if (!packageConfigFile.existsSync()) {
final originalConfigFile = File.fromUri((await Isolate.packageConfig)!);
final originalConfigFile = await _findPackageConfig();
final packageConfigContents = _scratchSpacePackageConfig(
originalConfigFile.readAsStringSync(),
originalConfigFile.absolute.uri,
Expand Down Expand Up @@ -134,3 +134,26 @@ String _scratchSpacePackageConfig(String rootConfig, Uri packageConfigUri) {
}

final Uri _currentDirUri = Directory.current.uri;

/// Returns [Isolate.packageConfig], or finds the file if it's `null`.
///
/// The `null` case is hit when the builder is AOT compiled. The build runs
/// within the package being built, so search upwards for the package config.
Future<File> _findPackageConfig() async {
final result = await Isolate.packageConfig;
if (result != null) return File(result.toFilePath());
var directory = Directory.current;
while (true) {
final packageConfigFile = File(
p.join(directory.path, '.dart_tool', 'package_config.json'),
);
if (packageConfigFile.existsSync()) {
return packageConfigFile;
}
final parent = directory.parent;
if (parent.path == directory.path) {
throw StateError('Failed to find package_config.json.');
}
directory = parent;
}
}
2 changes: 1 addition & 1 deletion build_modules/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_modules
version: 5.1.1
version: 5.1.2
description: >-
Builders to analyze and split Dart code into individually compilable modules
based on imports.
Expand Down
8 changes: 7 additions & 1 deletion build_runner/test/integration_tests/web_compilers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:test/test.dart';

import '../common/common.dart';

const defaultTimeout = Timeout(Duration(seconds: 90));
const defaultTimeout = Timeout(Duration(minutes: 3));

void main() async {
test('web compilers', () async {
Expand Down Expand Up @@ -55,6 +55,12 @@ void main() {
},
);

// Initial build AOT.
await tester.run(
'root_pkg',
'dart run build_runner build --output web:build --force-aot',
);

// Initial build.
await tester.run(
'root_pkg',
Expand Down