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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/compiler.dart

Issue 2342643003: Always write the source map even if it is inlined. (Closed)
Patch Set: Always write the source map even if it is inlined. This simplifies bazel rules. 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698