diff options
author | Jose <jose@zeroc.com> | 2017-05-05 13:38:01 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-05-05 13:38:01 +0200 |
commit | 6d727dc168ca88c1318717cb146065cbed95f4b2 (patch) | |
tree | e4d558215f173223613a0e7087b6fa7f38447997 /js/bin/HttpServer.js | |
parent | Removed operation attributes (used only by Freeze) (diff) | |
download | ice-6d727dc168ca88c1318717cb146065cbed95f4b2.tar.bz2 ice-6d727dc168ca88c1318717cb146065cbed95f4b2.tar.xz ice-6d727dc168ca88c1318717cb146065cbed95f4b2.zip |
Fix (ICE-7451) - Improve JavaScript source maps
Diffstat (limited to 'js/bin/HttpServer.js')
-rw-r--r-- | js/bin/HttpServer.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/js/bin/HttpServer.js b/js/bin/HttpServer.js index 5390d306be3..a3a3c52073f 100644 --- a/js/bin/HttpServer.js +++ b/js/bin/HttpServer.js @@ -231,6 +231,7 @@ function Init() } var filePath = req.url.pathname; + var sourceMap; if(filePath.indexOf("es5/") !== -1 && path.extname(filePath) != ".js") { // We only host JS files in the es5 subdirectory, other files @@ -238,14 +239,15 @@ function Init() filePath = filePath.replace("es5/", "") } filePath = path.resolve(path.join(basePath, filePath)) - + if(iceLib) + { + sourceMap = req.url.pathname.replace(".js", ".js.map"); + } // // If OPTIMIZE is set resolve Ice libraries to the corresponding minified // versions. // - // NOTE: only used minified versions with ES5 for now, they aren't supported with ES6 yet. - // - if(process.env.OPTIMIZE == "yes" && filePath.indexOf("es5/") !== -1) + if(process.env.OPTIMIZE == "yes") { if(iceLib && filePath.substr(-7) !== ".min.js") { @@ -273,12 +275,12 @@ function Init() fs.stat(filePath, function(err, stats) { - doRequest(err, stats, filePath); + doRequest(err, stats, filePath, sourceMap); }); } else { - doRequest(err, stats, filePath + ".gz"); + doRequest(err, stats, filePath + ".gz", sourceMap); } }); } @@ -287,11 +289,11 @@ function Init() fs.stat(filePath, function(err, stats) { - doRequest(err, stats, filePath); + doRequest(err, stats, filePath, sourceMap); }); } - var doRequest = function(err, stats, filePath) + var doRequest = function(err, stats, filePath, sourceMap) { if(err) { @@ -345,6 +347,11 @@ function Init() "Etag": hash.digest("hex") }; + if(sourceMap) + { + headers["X-SourceMap"] = sourceMap; + } + if(path.extname(filePath).slice(1) == "gz") { headers["Content-Encoding"] = "gzip"; |