Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: pkg/dev_compiler/web/web_command.dart

Issue 2303163002: Update web_command code so that it continues to use the legacy module loader. Drive by removal of m… (Closed)
Patch Set: Update web_command code so that it continues to use the legacy module loader. Drive by removal of m… Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/dev_compiler/web/main.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/web/web_command.dart
diff --git a/pkg/dev_compiler/web/web_command.dart b/pkg/dev_compiler/web/web_command.dart
index 171beb2666fe3e3c141d2c2581fb4b8f173188bb..dc101420c3f7d98936e9ba4d72d969bb5c13156a 100644
--- a/pkg/dev_compiler/web/web_command.dart
+++ b/pkg/dev_compiler/web/web_command.dart
@@ -33,6 +33,16 @@ import 'package:js/js.dart';
typedef void MessageHandler(Object message);
+@JS()
+@anonymous
+class CompileResult {
+ external factory CompileResult(
+ {String code, List<String> errors, bool isValid});
+}
+
+typedef CompileResult CompileModule(
+ String code, String libraryName, String fileName);
+
/// The command for invoking the modular compiler.
class WebCompileCommand extends Command {
get name => 'compile';
@@ -75,7 +85,7 @@ class WebCompileCommand extends Command {
(error) => onError('Dart sdk summaries failed to load: $error'));
}
- Function setUpCompile(List<int> sdkBytes, List<List<int>> summaryBytes,
+ CompileModule setUpCompile(List<int> sdkBytes, List<List<int>> summaryBytes,
List<String> summaryUrls) {
var resourceProvider = new MemoryResourceProvider();
var resourceUriResolver = new ResourceUriResolver(resourceProvider);
@@ -107,21 +117,24 @@ class WebCompileCommand extends Command {
var compilerOptions = new CompilerOptions.fromArguments(argResults);
- var compileFn = (String dart, int number) {
+ CompileModule compileFn =
+ (String sourceCode, String libraryName, String fileName) {
// Create a new virtual File that contains the given Dart source.
- resourceProvider.newFile("/expression${number}.dart", dart);
+ resourceProvider.newFile("/$fileName", sourceCode);
- var unit = new BuildUnit("expression${number}", "",
- ["file:///expression${number}.dart"], _moduleForLibrary);
+ var unit = new BuildUnit(
+ libraryName, "", ["file:///$fileName"], _moduleForLibrary);
JSModuleFile module = compiler.compile(unit, compilerOptions);
- module.errors.forEach(messageHandler);
- if (!module.isValid) throw new CompileErrorException();
+ var moduleCode = module.isValid
+ ? module
+ .getCode(ModuleFormat.legacy, unit.name, unit.name + '.map')
+ .code
+ : '';
- var code =
- module.getCode(ModuleFormat.amd, unit.name, unit.name + '.map');
- return code.code;
+ return new CompileResult(
+ code: moduleCode, isValid: module.isValid, errors: module.errors);
};
return allowInterop(compileFn);
« no previous file with comments | « pkg/dev_compiler/web/main.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698