feat(dart/transform): Allow absolute urls in templates

Allow `templateUrl` to be specified as an absolute `package:` import.
This commit is contained in:
Tim Blasi
2015-06-10 12:37:22 -07:00
parent 950f2a38cd
commit a187c782aa
11 changed files with 106 additions and 9 deletions

View File

@ -14,7 +14,8 @@ class XhrImpl implements XHR {
XhrImpl(this._reader, this._entryPoint);
Future<String> get(String url) async {
var assetId = uriToAssetId(_entryPoint, url, logger, null);
var assetId = uriToAssetId(_entryPoint, url, logger, null /* span */,
errorOnAbsolute: false);
var templateExists = await _reader.hasInput(assetId);
if (!templateExists) {
logger.error('Could not read template at uri $url from $_entryPoint');

View File

@ -113,7 +113,8 @@ Future<Map<UriBasedDirective, String>> _processNgImports(AssetReader reader,
.map((UriBasedDirective directive) {
var ngDepsUri = _toDepsUri(stringLiteralToString(directive.uri));
var spanArg = null;
var ngDepsAsset = uriToAssetId(entryPoint, ngDepsUri, logger, spanArg);
var ngDepsAsset = uriToAssetId(entryPoint, ngDepsUri, logger, spanArg,
errorOnAbsolute: false);
if (ngDepsAsset == entryPoint) return nullFuture;
return reader.hasInput(ngDepsAsset).then((hasInput) {
if (hasInput) {

View File

@ -37,7 +37,8 @@ Future<Map<String, DirectiveMetadata>> _extractDirectiveMetadataRecursive(
if (uri.startsWith('dart:')) return _nullFuture;
uri = toDepsExtension(uri);
var assetId = uriToAssetId(entryPoint, uri, logger, null /* span */);
var assetId = uriToAssetId(entryPoint, uri, logger, null /* span */,
errorOnAbsolute: false);
if (assetId == entryPoint) return _nullFuture;
return _extractDirectiveMetadataRecursive(reader, assetId)
.then((exportMap) {

View File

@ -97,8 +97,9 @@ class _ViewDefinitionCreator {
var prefix = node.prefix != null && node.prefix.name != null
? '${node.prefix.name}'
: null;
importAssetToPrefix[
uriToAssetId(entryPoint, uri, logger, null /* span */)] = prefix;
importAssetToPrefix[uriToAssetId(
entryPoint, uri, logger, null /* span */,
errorOnAbsolute: false)] = prefix;
}
}
return importAssetToPrefix;