| 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 | 8 |
| 9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
| 10 show AnalysisError, CompilationUnit, ErrorSeverity; | 10 show AnalysisError, CompilationUnit, ErrorSeverity; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 import 'package:analyzer/src/summary/package_bundle_reader.dart' | 25 import 'package:analyzer/src/summary/package_bundle_reader.dart' |
| 26 show InSummarySource, InputPackagesResultProvider, SummaryDataStore; | 26 show InSummarySource, InputPackagesResultProvider, SummaryDataStore; |
| 27 import 'package:args/args.dart' show ArgParser, ArgResults; | 27 import 'package:args/args.dart' show ArgParser, ArgResults; |
| 28 import 'package:args/src/usage_exception.dart' show UsageException; | 28 import 'package:args/src/usage_exception.dart' show UsageException; |
| 29 import 'package:func/func.dart' show Func1; | 29 import 'package:func/func.dart' show Func1; |
| 30 import 'package:path/path.dart' as path; | 30 import 'package:path/path.dart' as path; |
| 31 import 'package:source_maps/source_maps.dart'; | 31 import 'package:source_maps/source_maps.dart'; |
| 32 | 32 |
| 33 import '../analyzer/context.dart' show AnalyzerOptions, createSourceFactory; | 33 import '../analyzer/context.dart' show AnalyzerOptions, createSourceFactory; |
| 34 import '../js_ast/js_ast.dart' as JS; | 34 import '../js_ast/js_ast.dart' as JS; |
| 35 import '../js_ast/js_ast.dart' show js; |
| 35 import 'code_generator.dart' show CodeGenerator; | 36 import 'code_generator.dart' show CodeGenerator; |
| 36 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors; | 37 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors; |
| 37 import 'extension_types.dart' show ExtensionTypeSet; | 38 import 'extension_types.dart' show ExtensionTypeSet; |
| 38 import 'js_names.dart' as JS; | 39 import 'js_names.dart' as JS; |
| 39 import 'module_builder.dart' show transformModuleFormat, ModuleFormat; | 40 import 'module_builder.dart' show transformModuleFormat, ModuleFormat; |
| 40 import 'source_map_printer.dart' show SourceMapPrintingContext; | 41 import 'source_map_printer.dart' show SourceMapPrintingContext; |
| 41 | 42 |
| 42 /// Compiles a set of Dart files into a single JavaScript module. | 43 /// Compiles a set of Dart files into a single JavaScript module. |
| 43 /// | 44 /// |
| 44 /// For a single [BuildUnit] definition, this will produce a [JSModuleFile]. | 45 /// For a single [BuildUnit] definition, this will produce a [JSModuleFile]. |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 path.relative(path.fromUri(mapUrl), from: path.dirname(jsUrl))) | 503 path.relative(path.fromUri(mapUrl), from: path.dirname(jsUrl))) |
| 503 .toString(); | 504 .toString(); |
| 504 assert(path.dirname(jsUrl) == path.dirname(mapUrl)); | 505 assert(path.dirname(jsUrl) == path.dirname(mapUrl)); |
| 505 printer.emit('\n//# sourceMappingURL='); | 506 printer.emit('\n//# sourceMappingURL='); |
| 506 printer.emit(relativeMapUrl); | 507 printer.emit(relativeMapUrl); |
| 507 printer.emit('\n'); | 508 printer.emit('\n'); |
| 508 } | 509 } |
| 509 } | 510 } |
| 510 | 511 |
| 511 var text = printer.getText(); | 512 var text = printer.getText(); |
| 512 var rawSourceMap = options.inlineSourceMap ? builtMap : null; | 513 var rawSourceMap = options.inlineSourceMap |
| 513 text = text.replaceFirst(sourceMapHoleID, JSON.encode(rawSourceMap)); | 514 ? js.escapedString(JSON.encode(builtMap)).value |
| 515 : 'null'; |
| 516 text = text.replaceFirst(sourceMapHoleID, rawSourceMap); |
| 514 | 517 |
| 515 return new JSModuleCode(text, builtMap); | 518 return new JSModuleCode(text, builtMap); |
| 516 } | 519 } |
| 517 | 520 |
| 518 /// Similar to [getCode] but immediately writes the resulting files. | 521 /// Similar to [getCode] but immediately writes the resulting files. |
| 519 /// | 522 /// |
| 520 /// If [mapPath] is not supplied but [options.sourceMap] is set, mapPath | 523 /// If [mapPath] is not supplied but [options.sourceMap] is set, mapPath |
| 521 /// will default to [jsPath].map. | 524 /// will default to [jsPath].map. |
| 522 void writeCodeSync(ModuleFormat format, String jsPath, | 525 void writeCodeSync(ModuleFormat format, String jsPath, |
| 523 {bool singleOutFile: false}) { | 526 {bool singleOutFile: false}) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 /// are implementation details that would just confuse users. | 602 /// are implementation details that would just confuse users. |
| 600 /// Normalize sdk urls to use "dart:" for more understandable stack traces. | 603 /// Normalize sdk urls to use "dart:" for more understandable stack traces. |
| 601 Map cleanupSdkSourcemap(Map sourceMap) { | 604 Map cleanupSdkSourcemap(Map sourceMap) { |
| 602 var map = new Map.from(sourceMap); | 605 var map = new Map.from(sourceMap); |
| 603 var list = new List.from(map['sources']); | 606 var list = new List.from(map['sources']); |
| 604 map['sources'] = map['sources'] | 607 map['sources'] = map['sources'] |
| 605 .map((url) => url.contains('/_internal/') ? null : url) | 608 .map((url) => url.contains('/_internal/') ? null : url) |
| 606 .toList(); | 609 .toList(); |
| 607 return map; | 610 return map; |
| 608 } | 611 } |
| OLD | NEW |