| Index: lib/src/codegen/html_codegen.dart
|
| diff --git a/lib/src/codegen/html_codegen.dart b/lib/src/codegen/html_codegen.dart
|
| index f6f2332f630837fa433cc075ae561acfc3a4fd39..08ea0dc796c0b11a64d8349bea695069da905a41 100644
|
| --- a/lib/src/codegen/html_codegen.dart
|
| +++ b/lib/src/codegen/html_codegen.dart
|
| @@ -9,12 +9,10 @@ import 'package:html/parser.dart' show parseFragment;
|
| import 'package:logging/logging.dart' show Logger;
|
| import 'package:path/path.dart' as path;
|
|
|
| -import 'package:dev_compiler/src/dependency_graph.dart';
|
| -import 'package:dev_compiler/src/options.dart';
|
| +import 'package:dev_compiler/src/compiler.dart' show AbstractCompiler;
|
| +import 'package:dev_compiler/src/server/dependency_graph.dart';
|
| import 'package:dev_compiler/src/utils.dart' show colorOf, resourceOutputPath;
|
|
|
| -import 'js_codegen.dart' show jsOutputPath, jsOutputBase;
|
| -
|
| /// Emits an entry point HTML file corresponding to [inputFile] that can load
|
| /// the code generated by the dev compiler.
|
| ///
|
| @@ -24,7 +22,8 @@ import 'js_codegen.dart' show jsOutputPath, jsOutputBase;
|
| /// application. When compiling to Dart, we ensure that the document contains a
|
| /// single Dart script tag, but otherwise emit the original document
|
| /// unmodified.
|
| -String generateEntryHtml(HtmlSourceNode root, CompilerOptions options) {
|
| +String generateEntryHtml(HtmlSourceNode root, AbstractCompiler compiler) {
|
| + var options = compiler.options;
|
| var document = root.document.clone(true);
|
| var scripts = document.querySelectorAll('script[type="application/dart"]');
|
| if (scripts.isEmpty) {
|
| @@ -73,7 +72,7 @@ String generateEntryHtml(HtmlSourceNode root, CompilerOptions options) {
|
| resourcePath = _addHash(resourcePath, resource.cachingHash);
|
| }
|
| if (ext == '.js') {
|
| - fragment.nodes.add(_libraryInclude(resourcePath));
|
| + fragment.nodes.add(libraryInclude(resourcePath));
|
| } else if (ext == '.css') {
|
| var stylesheetLink = '<link rel="stylesheet" href="$resourcePath">\n';
|
| fragment.nodes.add(parseFragment(stylesheetLink));
|
| @@ -84,24 +83,29 @@ String generateEntryHtml(HtmlSourceNode root, CompilerOptions options) {
|
| for (var lib in libraries) {
|
| var info = lib.info;
|
| if (info == null) continue;
|
| - var jsPath = jsOutputPath(info.library, root.uri);
|
| - if (info.isEntry) mainLibraryName = jsOutputBase(info.library, root.uri);
|
| + var uri = info.library.source.uri;
|
| + var jsPath = compiler.getModulePath(uri);
|
| + if (info.isEntry) mainLibraryName = compiler.getModuleName(uri);
|
| if (lib.cachingHash != null) {
|
| jsPath = _addHash(jsPath, lib.cachingHash);
|
| }
|
| - fragment.nodes.add(_libraryInclude(jsPath));
|
| + fragment.nodes.add(libraryInclude(jsPath));
|
| }
|
| - fragment.nodes.add(_invokeMain(mainLibraryName));
|
| + fragment.nodes.add(invokeMain(mainLibraryName));
|
| scripts[0].replaceWith(fragment);
|
| return '${document.outerHtml}\n';
|
| }
|
|
|
| +// TODO(jmesserly): the string interpolation in these could lead to injection
|
| +// bugs. Not really a security issue since input is trusted, but the resulting
|
| +// parse tree may not match expectations if interpolated strings contain quotes.
|
| +
|
| /// A script tag that loads the .js code for a compiled library.
|
| -Node _libraryInclude(String jsUrl) =>
|
| +Node libraryInclude(String jsUrl) =>
|
| parseFragment('<script src="$jsUrl"></script>\n');
|
|
|
| /// A script tag that invokes the main function on the entry point library.
|
| -Node _invokeMain(String mainLibraryName) {
|
| +Node invokeMain(String mainLibraryName) {
|
| var code = mainLibraryName == null
|
| ? 'console.error("dev_compiler error: main was not generated");'
|
| // TODO(vsm): Can we simplify this?
|
|
|