| 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 | 4 |
| 5 import 'dart:collection' show HashSet, Queue; | 5 import 'dart:collection' show HashSet, Queue; |
| 6 import 'dart:convert' show BASE64, JSON, UTF8; | 6 import 'dart:convert' show BASE64, JSON, UTF8; |
| 7 import 'dart:io' show File; | 7 import 'dart:io' show File; |
| 8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; | 8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; |
| 9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
| 10 show AnalysisError, CompilationUnit, ErrorSeverity; | 10 show AnalysisError, CompilationUnit, ErrorSeverity; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 var code = getCode(format, singleOutFile, jsPath, mapPath); | 429 var code = getCode(format, singleOutFile, jsPath, mapPath); |
| 430 var c = code.code; | 430 var c = code.code; |
| 431 if (singleOutFile) { | 431 if (singleOutFile) { |
| 432 // In singleOutFile mode we wrap each module in an eval statement to | 432 // In singleOutFile mode we wrap each module in an eval statement to |
| 433 // leverage sourceURL to improve the debugging experience when source maps | 433 // leverage sourceURL to improve the debugging experience when source maps |
| 434 // are not enabled. | 434 // are not enabled. |
| 435 c += '\n//# sourceURL=${name}.js\n'; | 435 c += '\n//# sourceURL=${name}.js\n'; |
| 436 c = 'eval(${JSON.encode(c)});\n'; | 436 c = 'eval(${JSON.encode(c)});\n'; |
| 437 } | 437 } |
| 438 new File(jsPath).writeAsStringSync(c); | 438 new File(jsPath).writeAsStringSync(c); |
| 439 if (code.sourceMap != null && !options.inlineSourceMap) { | 439 // TODO(jacobr): it is a bit strange we are writing the source map to a file |
| 440 // even when options.inlineSourceMap is true. To be consistent perhaps we |
| 441 // should also write a copy of the source file without a sourcemap even when |
| 442 // inlineSourceMap is true. |
| 443 if (code.sourceMap != null) { |
| 440 new File(mapPath).writeAsStringSync(JSON.encode(code.sourceMap)); | 444 new File(mapPath).writeAsStringSync(JSON.encode(code.sourceMap)); |
| 441 } | 445 } |
| 442 } | 446 } |
| 443 } | 447 } |
| 444 | 448 |
| 445 /// The output of compiling a JavaScript module in a particular format. | 449 /// The output of compiling a JavaScript module in a particular format. |
| 446 class JSModuleCode { | 450 class JSModuleCode { |
| 447 /// The JavaScript code for this module. | 451 /// The JavaScript code for this module. |
| 448 /// | 452 /// |
| 449 /// If a [sourceMap] is available, this will include the `sourceMappingURL` | 453 /// If a [sourceMap] is available, this will include the `sourceMappingURL` |
| (...skipping 24 matching lines...) Expand all Loading... |
| 474 | 478 |
| 475 // Fall back to a relative path. | 479 // Fall back to a relative path. |
| 476 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); | 480 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); |
| 477 } | 481 } |
| 478 for (int i = 0; i < list.length; i++) { | 482 for (int i = 0; i < list.length; i++) { |
| 479 list[i] = transformUri(list[i]); | 483 list[i] = transformUri(list[i]); |
| 480 } | 484 } |
| 481 map['file'] = transformUri(map['file']); | 485 map['file'] = transformUri(map['file']); |
| 482 return map; | 486 return map; |
| 483 } | 487 } |
| OLD | NEW |