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

Side by Side Diff: lib/src/barback/dart2js_transformer.dart

Issue 2653753010: Fix URI for packages: make them self contained within the domain served by pub-serve (Closed)
Patch Set: Created 3 years, 11 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 | test/dart2js/source_maps_are_self_contained_test.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 import 'package:analyzer/analyzer.dart'; 8 import 'package:analyzer/analyzer.dart';
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:collection/collection.dart'; 10 import 'package:collection/collection.dart';
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 var provider = new _BarbackCompilerProvider(_environment, transform, 118 var provider = new _BarbackCompilerProvider(_environment, transform,
119 generateSourceMaps: _generateSourceMaps); 119 generateSourceMaps: _generateSourceMaps);
120 120
121 // Create a "path" to the entrypoint script. The entrypoint may not actually 121 // Create a "path" to the entrypoint script. The entrypoint may not actually
122 // be on disk, but this gives dart2js a root to resolve relative paths 122 // be on disk, but this gives dart2js a root to resolve relative paths
123 // against. 123 // against.
124 var id = transform.primaryInput.id; 124 var id = transform.primaryInput.id;
125 125
126 var entrypoint = _environment.graph.packages[id.package].path(id.path); 126 var entrypoint = _environment.graph.packages[id.package].path(id.path);
127 127
128 // We define the packageRoot in terms of the entrypoint directory, and not
129 // the rootPackage, to ensure that the generated source-maps are valid.
130 // Source-maps contain relative URLs to package sources and these relative
131 // URLs should be self-contained within the paths served by pub-serve.
132 // See #1511 for details.
133 var buildDir = _environment.getSourceDirectoryContaining(id.path);
134 var packageRoot = _environment.rootPackage.path(buildDir, "packages");
135
128 // TODO(rnystrom): Should have more sophisticated error-handling here. Need 136 // TODO(rnystrom): Should have more sophisticated error-handling here. Need
129 // to report compile errors to the user in an easily visible way. Need to 137 // to report compile errors to the user in an easily visible way. Need to
130 // make sure paths in errors are mapped to the original source path so they 138 // make sure paths in errors are mapped to the original source path so they
131 // can understand them. 139 // can understand them.
132 return dart.compile( 140 return dart.compile(
133 entrypoint, provider, 141 entrypoint, provider,
134 commandLineOptions: _configCommandLineOptions, 142 commandLineOptions: _configCommandLineOptions,
135 csp: _configBool('csp'), 143 csp: _configBool('csp'),
136 checked: _configBool('checked'), 144 checked: _configBool('checked'),
137 minify: _configBool( 145 minify: _configBool(
138 'minify', defaultsTo: _settings.mode == BarbackMode.RELEASE), 146 'minify', defaultsTo: _settings.mode == BarbackMode.RELEASE),
139 verbose: _configBool('verbose'), 147 verbose: _configBool('verbose'),
140 environment: _configEnvironment, 148 environment: _configEnvironment,
141 packageRoot: _environment.rootPackage.path("packages"), 149 packageRoot: packageRoot,
142 analyzeAll: _configBool('analyzeAll'), 150 analyzeAll: _configBool('analyzeAll'),
143 preserveUris: _configBool('preserveUris'), 151 preserveUris: _configBool('preserveUris'),
144 suppressWarnings: _configBool('suppressWarnings'), 152 suppressWarnings: _configBool('suppressWarnings'),
145 suppressHints: _configBool('suppressHints'), 153 suppressHints: _configBool('suppressHints'),
146 suppressPackageWarnings: _configBool( 154 suppressPackageWarnings: _configBool(
147 'suppressPackageWarnings', defaultsTo: true), 155 'suppressPackageWarnings', defaultsTo: true),
148 terse: _configBool('terse'), 156 terse: _configBool('terse'),
149 includeSourceMapUrls: _generateSourceMaps); 157 includeSourceMapUrls: _generateSourceMaps);
150 } 158 }
151 159
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 420 }
413 } 421 }
414 422
415 /// An [EventSink] that discards all data. Provided to dart2js when we don't 423 /// An [EventSink] that discards all data. Provided to dart2js when we don't
416 /// want an actual output. 424 /// want an actual output.
417 class NullSink<T> implements EventSink<T> { 425 class NullSink<T> implements EventSink<T> {
418 void add(T event) {} 426 void add(T event) {}
419 void addError(errorEvent, [StackTrace stackTrace]) {} 427 void addError(errorEvent, [StackTrace stackTrace]) {}
420 void close() {} 428 void close() {}
421 } 429 }
OLDNEW
« no previous file with comments | « no previous file | test/dart2js/source_maps_are_self_contained_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698