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.
This commit is contained in:
@@ -132,7 +132,7 @@ abstract class Dart2WebTarget extends Target {
|
||||
|
||||
@override
|
||||
List<Source> get outputs => buildFiles.map(
|
||||
(String file) => Source.pattern('{OUTPUT_DIR}/$file')
|
||||
(String file) => Source.pattern('{BUILD_DIR}/$file')
|
||||
).toList();
|
||||
|
||||
@override
|
||||
@@ -353,9 +353,6 @@ class Dart2WasmTarget extends Dart2WebTarget {
|
||||
'dart2wasm.d',
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get outputs => const <Source>[];
|
||||
|
||||
@override
|
||||
Map<String, Object?> get buildConfig => <String, Object?>{
|
||||
'compileTarget': 'dart2wasm',
|
||||
@@ -401,10 +398,13 @@ class WebReleaseBundle extends Target {
|
||||
@override
|
||||
List<Source> get inputs => <Source>[
|
||||
const Source.pattern('{PROJECT_DIR}/pubspec.yaml'),
|
||||
...buildFiles.map((String file) => Source.pattern('{BUILD_DIR}/$file'))
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get outputs => <Source>[];
|
||||
List<Source> get outputs => <Source>[
|
||||
...buildFiles.map((String file) => Source.pattern('{OUTPUT_DIR}/$file'))
|
||||
];
|
||||
|
||||
@override
|
||||
List<String> get depfiles => const <String>[
|
||||
|
||||
@@ -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 {
|
||||
final File mainFile = globals.fs.file(globals.fs.path.join('other', 'lib', 'main.dart'))
|
||||
..createSync(recursive: true)
|
||||
|
||||
Reference in New Issue
Block a user