Identify app.js source map using a special comment

If we're going to minify third party code, the size heuristic may not hold
anymore.

(imported from commit 78ada1fee1446e78b3b1ad299ee3e975d1cd9002)
This commit is contained in:
Keegan McAllister 2013-04-05 17:52:13 -04:00 committed by Zev Benjamin
parent 5aafdc7cf9
commit 371d0dbaa0
2 changed files with 9 additions and 6 deletions

View File

@ -12,13 +12,11 @@ class ClosureSourceMapCompressor(SubProcessCompressor):
# easily get either the input file names or the output file
# name. So we just pick a unique arbitrary name. This is
# okay because we can figure out from the source map file
# contents which JavaScript files it corresponds to.
# contents which JavaScript files it corresponds to. But we
# use a special comment to identify app.js, so that automatic
# source mapping works.
# As a hack to make things easier, assume that any large input
# corresponds to app.js. This is like 60 times bigger than
# any other input file, at present.
if len(js) > 100000:
if 'MINIFY-FILE-ID: zephyr.js' in js:
source_map_name = 'app.js.map'
else:
source_map_name = sha1(js).hexdigest() + '.map'

View File

@ -1,3 +1,8 @@
// zephyr/lib/minify.py will look for this comment in order to tell when it's
// producing app.js:
//
// MINIFY-FILE-ID: zephyr.js
var all_msg_list = new MessageList();
var home_msg_list = new MessageList('zhome', new narrow.Filter([["in", "home"]]));
var narrowed_msg_list;