Unverified Commit c411f588 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "[flutter_tools] supports tree-shake-icons for web builds (#51808)" (#52045)

This reverts commit aed96199.
parent ee476a7b
...@@ -289,7 +289,7 @@ class IconTreeShaker { ...@@ -289,7 +289,7 @@ class IconTreeShaker {
for (final Map<String, dynamic> iconDataMap in consts.constantInstances) { for (final Map<String, dynamic> iconDataMap in consts.constantInstances) {
if ((iconDataMap['fontPackage'] ?? '') is! String || // Null is ok here. if ((iconDataMap['fontPackage'] ?? '') is! String || // Null is ok here.
iconDataMap['fontFamily'] is! String || iconDataMap['fontFamily'] is! String ||
iconDataMap['codePoint'] is! num) { iconDataMap['codePoint'] is! int) {
throw IconTreeShakerException._( throw IconTreeShakerException._(
'Invalid ConstFinder result. Expected "fontPackage" to be a String, ' 'Invalid ConstFinder result. Expected "fontPackage" to be a String, '
'"fontFamily" to be a String, and "codePoint" to be an int, ' '"fontFamily" to be a String, and "codePoint" to be an int, '
...@@ -301,7 +301,7 @@ class IconTreeShaker { ...@@ -301,7 +301,7 @@ class IconTreeShaker {
? family ? family
: 'packages/$package/$family'; : 'packages/$package/$family';
result[key] ??= <int>[]; result[key] ??= <int>[];
result[key].add((iconDataMap['codePoint'] as num).round()); result[key].add(iconDataMap['codePoint'] as int);
} }
return result; return result;
} }
......
...@@ -156,51 +156,36 @@ class Dart2JSTarget extends Target { ...@@ -156,51 +156,36 @@ class Dart2JSTarget extends Target {
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]); final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
final String specPath = globals.fs.path.join(globals.artifacts.getArtifactPath(Artifact.flutterWebSdk), 'libraries.json'); final String specPath = globals.fs.path.join(globals.artifacts.getArtifactPath(Artifact.flutterWebSdk), 'libraries.json');
final String packageFile = PackageMap.globalPackagesPath; final String packageFile = PackageMap.globalPackagesPath;
final File outputKernel = environment.buildDir.childFile('app.dill');
final File outputFile = environment.buildDir.childFile('main.dart.js'); final File outputFile = environment.buildDir.childFile('main.dart.js');
// Run the dart2js compilation in two stages, so that icon tree shaking can final ProcessResult result = await globals.processManager.run(<String>[
// parse the kernel file for web builds.
final ProcessResult kernelResult = await globals.processManager.run(<String>[
globals.artifacts.getArtifactPath(Artifact.engineDartBinary), globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
globals.artifacts.getArtifactPath(Artifact.dart2jsSnapshot), globals.artifacts.getArtifactPath(Artifact.dart2jsSnapshot),
'--libraries-spec=$specPath', '--libraries-spec=$specPath',
if (dart2jsOptimization != null)
'-$dart2jsOptimization'
else
'-O4',
if (buildMode == BuildMode.profile)
'--no-minify',
'-o', '-o',
outputKernel.path, outputFile.path,
'--packages=$packageFile', '--packages=$packageFile',
if (buildMode == BuildMode.profile) if (buildMode == BuildMode.profile)
'-Ddart.vm.profile=true' '-Ddart.vm.profile=true'
else else
'-Ddart.vm.product=true', '-Ddart.vm.product=true',
if (csp)
'--csp',
for (final String dartDefine in parseDartDefines(environment)) for (final String dartDefine in parseDartDefines(environment))
'-D$dartDefine', '-D$dartDefine',
'--cfe-only',
environment.buildDir.childFile('main.dart').path, environment.buildDir.childFile('main.dart').path,
]); ]);
if (kernelResult.exitCode != 0) { if (result.exitCode != 0) {
throw Exception(kernelResult.stdout + kernelResult.stderr); throw Exception(result.stdout + result.stderr);
}
final ProcessResult javaScriptResult = await globals.processManager.run(<String>[
globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
globals.artifacts.getArtifactPath(Artifact.dart2jsSnapshot),
'--libraries-spec=$specPath',
if (dart2jsOptimization != null)
'-$dart2jsOptimization'
else
'-O4',
if (buildMode == BuildMode.profile)
'--no-minify',
if (csp)
'--csp',
'-o',
outputFile.path,
environment.buildDir.childFile('app.dill').path,
]);
if (javaScriptResult.exitCode != 0) {
throw Exception(javaScriptResult.stdout + javaScriptResult.stderr);
} }
final File dart2jsDeps = environment.buildDir final File dart2jsDeps = environment.buildDir
.childFile('app.dill.deps'); .childFile('main.dart.js.deps');
if (!dart2jsDeps.existsSync()) { if (!dart2jsDeps.existsSync()) {
globals.printError('Warning: dart2js did not produced expected deps list at ' globals.printError('Warning: dart2js did not produced expected deps list at '
'${dart2jsDeps.path}'); '${dart2jsDeps.path}');
...@@ -212,7 +197,7 @@ class Dart2JSTarget extends Target { ...@@ -212,7 +197,7 @@ class Dart2JSTarget extends Target {
platform: globals.platform, platform: globals.platform,
); );
final Depfile depfile = depfileService.parseDart2js( final Depfile depfile = depfileService.parseDart2js(
environment.buildDir.childFile('app.dill.deps'), environment.buildDir.childFile('main.dart.js.deps'),
outputFile, outputFile,
); );
depfileService.writeToFile( depfileService.writeToFile(
......
...@@ -11,7 +11,6 @@ import '../base/logger.dart'; ...@@ -11,7 +11,6 @@ import '../base/logger.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../build_system/build_system.dart'; import '../build_system/build_system.dart';
import '../build_system/targets/dart.dart'; import '../build_system/targets/dart.dart';
import '../build_system/targets/icon_tree_shaker.dart';
import '../build_system/targets/web.dart'; import '../build_system/targets/web.dart';
import '../convert.dart'; import '../convert.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
...@@ -53,7 +52,8 @@ Future<void> buildWeb( ...@@ -53,7 +52,8 @@ Future<void> buildWeb(
kHasWebPlugins: hasWebPlugins.toString(), kHasWebPlugins: hasWebPlugins.toString(),
kDartDefines: jsonEncode(dartDefines), kDartDefines: jsonEncode(dartDefines),
kCspMode: csp.toString(), kCspMode: csp.toString(),
kIconTreeShakerFlag: buildInfo.treeShakeIcons.toString(), // TODO(dnfield): Enable font subset. We need to get a kernel file to do
// that. https://github.com/flutter/flutter/issues/49730
}, },
)); ));
if (!result.success) { if (!result.success) {
......
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