mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Use compiled.js in dev environments.
Make our dev setup more similar to prod by using compiled.js, instead of AJAX-ing templates on the fly and compiling them with non-node code. This will make our dev environment more consistent with prod (to avoid surprising bugs), plus it should be faster (fewer AJAX calls). This change also means we don't have to keep two copies of static/third/handlebars/handlebars.js around. (imported from commit d8d584b9aa13adcdcce7e424033610d77d2df79b)
This commit is contained in:
		
				
					committed by
					
						
						Waseem Daher
					
				
			
			
				
	
			
			
			
						parent
						
							1ad82b1f70
						
					
				
				
					commit
					2504baf783
				
			@@ -4,24 +4,13 @@ var exports = {};
 | 
			
		||||
 | 
			
		||||
exports.render = function (name, arg) {
 | 
			
		||||
     if (Handlebars.templates === undefined) {
 | 
			
		||||
        Handlebars.templates = {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (Handlebars.templates[name] === undefined) {
 | 
			
		||||
        // Fetch the template using a synchronous AJAX request.
 | 
			
		||||
        //
 | 
			
		||||
        // This is only for local development.  In prod we precompile
 | 
			
		||||
        // templates and serve JavaScript which will have already
 | 
			
		||||
        // populated Handlebars.templates.
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url:     '/static/templates/'+name+'.handlebars?' + new Date().getTime(),
 | 
			
		||||
            async:   false,
 | 
			
		||||
            success: function (data) {
 | 
			
		||||
                Handlebars.templates[name] = Handlebars.compile(data);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        throw "Cannot find compiled templates!";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // The templates should be compiled into compiled.js.  In
 | 
			
		||||
    // prod we build compiled.js as part of the deployment process,
 | 
			
		||||
    // and for devs we have run_dev.py build compiled.js when templates
 | 
			
		||||
    // change.
 | 
			
		||||
    return Handlebars.templates[name](arg);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -487,10 +487,8 @@ JS_SPECS = {
 | 
			
		||||
            'third/spectrum/spectrum.js',
 | 
			
		||||
            'third/winchan/winchan.js',
 | 
			
		||||
            'third/sockjs/sockjs-0.3.4.js',
 | 
			
		||||
            ('third/handlebars/handlebars.runtime.js'
 | 
			
		||||
                if PIPELINE
 | 
			
		||||
                else 'third/handlebars/handlebars.js'),
 | 
			
		||||
 | 
			
		||||
            'third/handlebars/handlebars.runtime.js',
 | 
			
		||||
            'templates/compiled.js',
 | 
			
		||||
            'js/feature_flags.js',
 | 
			
		||||
            'js/summary.js',
 | 
			
		||||
            'js/util.js',
 | 
			
		||||
@@ -559,12 +557,6 @@ JS_SPECS = {
 | 
			
		||||
 | 
			
		||||
app_srcs = JS_SPECS['app']['source_filenames']
 | 
			
		||||
 | 
			
		||||
if not DEBUG:
 | 
			
		||||
    # This file is generated by update-prod-static.
 | 
			
		||||
    # In dev we fetch individual templates using Ajax.
 | 
			
		||||
    app_srcs.insert(app_srcs.index('third/handlebars/handlebars.runtime.js') + 1,
 | 
			
		||||
                    'templates/compiled.js')
 | 
			
		||||
 | 
			
		||||
if MIXPANEL_TOKEN:
 | 
			
		||||
    # Mixpanel is not used on enterprise and throws an error when the
 | 
			
		||||
    # library is not included
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user