Consume flutter.js from the engine artifacts. (#137113)
Work in progress... currently testing against presubmit.
This commit is contained in:
@@ -15,7 +15,6 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/html_utils.dart';
|
||||
import 'package:flutter_tools/src/isolated/mustache_template.dart';
|
||||
import 'package:flutter_tools/src/web/compile.dart';
|
||||
import 'package:flutter_tools/src/web/file_generators/flutter_js.dart' as flutter_js;
|
||||
import 'package:flutter_tools/src/web/file_generators/flutter_service_worker_js.dart';
|
||||
|
||||
import '../../../src/common.dart';
|
||||
@@ -70,6 +69,8 @@ void main() {
|
||||
..writeAsStringSync('foo:foo/lib/\n');
|
||||
globals.fs.currentDirectory.childDirectory('bar').createSync();
|
||||
processManager = FakeProcessManager.empty();
|
||||
globals.fs.file('bin/cache/flutter_web_sdk/flutter_js/flutter.js')
|
||||
.createSync(recursive: true);
|
||||
|
||||
environment = Environment.test(
|
||||
globals.fs.currentDirectory,
|
||||
@@ -1056,41 +1057,6 @@ void main() {
|
||||
contains('"main.dart.js"'));
|
||||
}));
|
||||
|
||||
test('flutter.js sanity checks', () => testbed.run(() {
|
||||
final String fileGeneratorsPath = environment.artifacts
|
||||
.getArtifactPath(Artifact.flutterToolsFileGenerators);
|
||||
final String flutterJsContents =
|
||||
flutter_js.generateFlutterJsFile(fileGeneratorsPath);
|
||||
expect(flutterJsContents, contains('"use strict";'));
|
||||
expect(flutterJsContents, contains('main.dart.js'));
|
||||
expect(flutterJsContents, contains('if (!("serviceWorker" in navigator))'));
|
||||
expect(flutterJsContents, contains(r'/\.js$/,'));
|
||||
expect(flutterJsContents, contains('flutter_service_worker.js?v='));
|
||||
expect(flutterJsContents, contains('document.createElement("script")'));
|
||||
expect(flutterJsContents, contains('"application/javascript"'));
|
||||
expect(flutterJsContents, contains('const baseUri = '));
|
||||
expect(flutterJsContents, contains('document.querySelector("base")'));
|
||||
expect(flutterJsContents, contains('.getAttribute("href")'));
|
||||
}));
|
||||
|
||||
test('flutter.js is not dynamically generated', () => testbed.run(() async {
|
||||
globals.fs.file('bin/cache/flutter_web_sdk/canvaskit/foo')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('OL');
|
||||
|
||||
await WebBuiltInAssets(globals.fs, WebRendererMode.auto, isWasm: false).build(environment);
|
||||
|
||||
// No caching of source maps.
|
||||
final String fileGeneratorsPath = environment.artifacts
|
||||
.getArtifactPath(Artifact.flutterToolsFileGenerators);
|
||||
final String flutterJsContents =
|
||||
flutter_js.generateFlutterJsFile(fileGeneratorsPath);
|
||||
expect(
|
||||
environment.outputDir.childFile('flutter.js').readAsStringSync(),
|
||||
equals(flutterJsContents),
|
||||
);
|
||||
}));
|
||||
|
||||
test('wasm build copies and generates specific files', () => testbed.run(() async {
|
||||
globals.fs.file('bin/cache/flutter_web_sdk/canvaskit/canvaskit.wasm')
|
||||
.createSync(recursive: true);
|
||||
|
||||
@@ -685,6 +685,7 @@ void main() {
|
||||
nullSafetyMode: NullSafetyMode.unsound,
|
||||
);
|
||||
webDevFS.requireJS.createSync(recursive: true);
|
||||
webDevFS.flutterJs.createSync(recursive: true);
|
||||
webDevFS.stackTraceMapper.createSync(recursive: true);
|
||||
|
||||
final Uri uri = await webDevFS.create();
|
||||
@@ -798,6 +799,7 @@ void main() {
|
||||
nullSafetyMode: NullSafetyMode.sound,
|
||||
);
|
||||
webDevFS.requireJS.createSync(recursive: true);
|
||||
webDevFS.flutterJs.createSync(recursive: true);
|
||||
webDevFS.stackTraceMapper.createSync(recursive: true);
|
||||
|
||||
final Uri uri = await webDevFS.create();
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/web/file_generators/flutter_js.dart';
|
||||
|
||||
import '../test_utils.dart';
|
||||
import 'deferred_components_config.dart';
|
||||
@@ -60,13 +58,9 @@ abstract class Project {
|
||||
}
|
||||
deferredComponents?.setUpIn(dir);
|
||||
|
||||
final String fileGeneratorsPath =
|
||||
Artifacts.test().getArtifactPath(Artifact.flutterToolsFileGenerators);
|
||||
final String flutterJsContents = generateFlutterJsFile(fileGeneratorsPath);
|
||||
|
||||
// Setup for different flutter web initializations
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'index.html'), indexHtml);
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter.js'), flutterJsContents);
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter.js'), '');
|
||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter_service_worker.js'), '');
|
||||
writePackages(dir.path);
|
||||
await getPackages(dir.path);
|
||||
|
||||
Reference in New Issue
Block a user