From 7516fbce3ee15b398018da9c9093b42d27d0e32f Mon Sep 17 00:00:00 2001 From: Kostas Chatzikokolakis Date: Thu, 22 Feb 2018 19:26:09 +0100 Subject: [PATCH] Closure: prefix paths by file://, create sourceMappingURL --- lime/tools/helpers/HTML5Helper.hx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lime/tools/helpers/HTML5Helper.hx b/lime/tools/helpers/HTML5Helper.hx index d57c34d95..69970af2a 100644 --- a/lime/tools/helpers/HTML5Helper.hx +++ b/lime/tools/helpers/HTML5Helper.hx @@ -193,16 +193,14 @@ class HTML5Helper { if (FileSystem.exists (sourceFile + ".map") || project.targetFlags.exists ("source-map")) { + // if an input .js.map exists closure automatically detects it (from sourceMappingURL) + // --source_map_location_mapping adds file:// to paths (similarly to haxe's .js.map) + args.push ("--create_source_map"); args.push (tempFile + ".map"); + args.push ("--source_map_location_mapping"); + args.push ("/|file:///"); - if (FileSystem.exists (sourceFile + ".map")) { - - args.push ("--source_map_input"); - args.push (sourceFile + "|" + sourceFile + ".map"); - - } - } if (!LogHelper.verbose) { @@ -215,6 +213,11 @@ class HTML5Helper { if (FileSystem.exists (tempFile + ".map")) { + // closure does not include a sourceMappingURL in the created .js, we do it here + var f = File.append (tempFile); + f.writeString ("//# sourceMappingURL=" + Path.withoutDirectory (sourceFile) + ".map"); + f.close (); + File.copy (tempFile + ".map", sourceFile + ".map"); FileSystem.deleteFile (tempFile + ".map");