meteor icon indicating copy to clipboard operation
meteor copied to clipboard

add package only for serverside use?

Open raix opened this issue 13 years ago • 4 comments

I'm wondering if I Meteor add http but only use the code on the server - is it then becoming extra payload on the client? If so an option for installing package on client or server would be nice - Even better in general: Strip un used code when minifying? (I know this part is near impossible, but duable to some degree?)

raix avatar Feb 12 '13 10:02 raix

Yes! The medium-term goal is definitely to improve the bundler so that packages like http can be included on just the server, just the client, or both, at your choice.

I also love the idea of stripping unused code while minifying, at least in the common case of having a large library of functions of which you use only one or two, similar to how C linkers work.

gschmidt avatar Feb 13 '13 01:02 gschmidt

@gschmidt: Cool, yep some like linkers in C - guess it's a bit harder to do in js since we can call functions in many ways and dynamicly, lazy loading etc.

raix avatar Feb 13 '13 06:02 raix

@gschmidt: do you think it would be possible to run something like google's closure compiler on the bundled client code?

Maybe somethiing like:

/* <-- bundle just created */
/* Check if bundle-compiled.js exists if so then remove */
var compileBundle = exec(
        'java -jar compiler.jar '+
        '--compilation_level ADVANCED_OPTIMIZATIONS '+
        '--js bundle.js '+
        '--js_output_file bundle-compiled.js', 
                function(error, stdout, stderr) {
                    //Callback function called with the output when process terminates
                    if (error === null) { //if child proc closed, normally
                        /* Check if bundle-compiled.js exists */
                        /* If so, send it to client */
                        /* Otherwise send normal bundle and write message on server console / log */
                        /* Continue work in bundler */
                    }
                }
        );
/* send bundle to client --> */

https://developers.google.com/closure/compiler/docs/api-tutorial3?hl=fi

Would be even cool'er if code could be split - eg. first bundle add all Meteor.startup, init functions run at startup/onload/onready/etc. - to maximize initial load and then lazy load the rest - this lazy functionality could be provided in same sense as the reload hot code push (without actually reloading the whole page, keeping data, filepointer etc. intact for patching) - Not to speak about precompiling for multiple browsers/languages/styles somewhat like the gwt compiler does

raix avatar Feb 13 '13 08:02 raix

+1 for closure compiler support

benmccann avatar Feb 22 '13 01:02 benmccann