Unverified Commit 2aef6c57 authored by Jackson Gardner's avatar Jackson Gardner Committed by GitHub

Fix inputs and outputs for `WebReleaseBundle` (#143023)

Since `WebReleaseBundle` is responsible for copying over the outputs from the subtargets, so it needs to be reflected in inputs and outputs so that things will be recopied when something changes.
parent 9fccb32a
...@@ -132,7 +132,7 @@ abstract class Dart2WebTarget extends Target { ...@@ -132,7 +132,7 @@ abstract class Dart2WebTarget extends Target {
@override @override
List<Source> get outputs => buildFiles.map( List<Source> get outputs => buildFiles.map(
(String file) => Source.pattern('{OUTPUT_DIR}/$file') (String file) => Source.pattern('{BUILD_DIR}/$file')
).toList(); ).toList();
@override @override
...@@ -353,9 +353,6 @@ class Dart2WasmTarget extends Dart2WebTarget { ...@@ -353,9 +353,6 @@ class Dart2WasmTarget extends Dart2WebTarget {
'dart2wasm.d', 'dart2wasm.d',
]; ];
@override
List<Source> get outputs => const <Source>[];
@override @override
Map<String, Object?> get buildConfig => <String, Object?>{ Map<String, Object?> get buildConfig => <String, Object?>{
'compileTarget': 'dart2wasm', 'compileTarget': 'dart2wasm',
...@@ -401,10 +398,13 @@ class WebReleaseBundle extends Target { ...@@ -401,10 +398,13 @@ class WebReleaseBundle extends Target {
@override @override
List<Source> get inputs => <Source>[ List<Source> get inputs => <Source>[
const Source.pattern('{PROJECT_DIR}/pubspec.yaml'), const Source.pattern('{PROJECT_DIR}/pubspec.yaml'),
...buildFiles.map((String file) => Source.pattern('{BUILD_DIR}/$file'))
]; ];
@override @override
List<Source> get outputs => <Source>[]; List<Source> get outputs => <Source>[
...buildFiles.map((String file) => Source.pattern('{OUTPUT_DIR}/$file'))
];
@override @override
List<String> get depfiles => const <String>[ List<String> get depfiles => const <String>[
......
...@@ -220,6 +220,35 @@ void main() { ...@@ -220,6 +220,35 @@ void main() {
)); ));
})); }));
test('WebReleaseBundle copies over output files when they change', () => testbed.run(() async {
final Directory webResources = environment.projectDir.childDirectory('web');
webResources.childFile('foo.txt')
..createSync(recursive: true)
..writeAsStringSync('A');
environment.buildDir.childFile('main.dart.wasm')..createSync()..writeAsStringSync('old wasm');
environment.buildDir.childFile('main.dart.mjs')..createSync()..writeAsStringSync('old mjs');
await WebReleaseBundle(<WebCompilerConfig>[
const WasmCompilerConfig()
]).build(environment);
expect(environment.outputDir.childFile('main.dart.wasm')
.readAsStringSync(), 'old wasm');
expect(environment.outputDir.childFile('main.dart.mjs')
.readAsStringSync(), 'old mjs');
environment.buildDir.childFile('main.dart.wasm')..createSync()..writeAsStringSync('new wasm');
environment.buildDir.childFile('main.dart.mjs')..createSync()..writeAsStringSync('new mjs');
await WebReleaseBundle(<WebCompilerConfig>[
const WasmCompilerConfig()
]).build(environment);
expect(environment.outputDir.childFile('main.dart.wasm')
.readAsStringSync(), 'new wasm');
expect(environment.outputDir.childFile('main.dart.mjs')
.readAsStringSync(), 'new mjs');
}));
test('WebEntrypointTarget generates an entrypoint for a file outside of main', () => testbed.run(() async { test('WebEntrypointTarget generates an entrypoint for a file outside of main', () => testbed.run(() async {
final File mainFile = globals.fs.file(globals.fs.path.join('other', 'lib', 'main.dart')) final File mainFile = globals.fs.file(globals.fs.path.join('other', 'lib', 'main.dart'))
..createSync(recursive: true) ..createSync(recursive: true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment