OLD | NEW |
---|---|
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 @JS() | 4 @JS() |
5 library dev_compiler.web.web_command; | 5 library dev_compiler.web.web_command; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html' show HttpRequest; | 8 import 'dart:html' show HttpRequest; |
9 import 'dart:convert' show BASE64; | 9 import 'dart:convert' show BASE64; |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 // Create a new virtual File that contains the given Dart source. | 122 // Create a new virtual File that contains the given Dart source. |
123 resourceProvider.newFile("/$fileName", sourceCode); | 123 resourceProvider.newFile("/$fileName", sourceCode); |
124 | 124 |
125 var unit = new BuildUnit( | 125 var unit = new BuildUnit( |
126 libraryName, "", ["file:///$fileName"], _moduleForLibrary); | 126 libraryName, "", ["file:///$fileName"], _moduleForLibrary); |
127 | 127 |
128 JSModuleFile module = compiler.compile(unit, compilerOptions); | 128 JSModuleFile module = compiler.compile(unit, compilerOptions); |
129 | 129 |
130 var moduleCode = module.isValid | 130 var moduleCode = module.isValid |
131 ? module | 131 ? module |
132 .getCode(ModuleFormat.legacy, unit.name, unit.name + '.map') | 132 .getCode(ModuleFormat.legacy, false, unit.name, unit.name + '.map' ) |
Jennifer Messerly
2016/09/14 20:07:03
long line, maybe run format?
| |
133 .code | 133 .code |
134 : ''; | 134 : ''; |
135 | 135 |
136 return new CompileResult( | 136 return new CompileResult( |
137 code: moduleCode, isValid: module.isValid, errors: module.errors); | 137 code: moduleCode, isValid: module.isValid, errors: module.errors); |
138 }; | 138 }; |
139 | 139 |
140 return allowInterop(compileFn); | 140 return allowInterop(compileFn); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 // Given path, determine corresponding dart library. | 144 // Given path, determine corresponding dart library. |
145 String _moduleForLibrary(source) { | 145 String _moduleForLibrary(source) { |
146 if (source is InSummarySource) { | 146 if (source is InSummarySource) { |
147 return source.summaryPath.substring(1).replaceAll('.api.ds', ''); | 147 return source.summaryPath.substring(1).replaceAll('.api.ds', ''); |
148 } | 148 } |
149 return source.toString().substring(1).replaceAll('.dart', ''); | 149 return source.toString().substring(1).replaceAll('.dart', ''); |
150 } | 150 } |
151 | 151 |
152 /// Thrown when the input source code has errors. | 152 /// Thrown when the input source code has errors. |
153 class CompileErrorException implements Exception { | 153 class CompileErrorException implements Exception { |
154 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; | 154 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; |
155 } | 155 } |
OLD | NEW |