Merge lp:~deryck/launchpad/minify-app-specific-js-592795 into lp:launchpad

Proposed by Deryck Hodge
Status: Merged
Approved by: Deryck Hodge
Approved revision: no longer in the source branch.
Merged at revision: 11009
Proposed branch: lp:~deryck/launchpad/minify-app-specific-js-592795
Merge into: lp:launchpad
Diff against target: 55 lines (+19/-4)
2 files modified
Makefile (+1/-1)
utilities/lp-deps.py (+18/-3)
To merge this branch: bzr merge lp:~deryck/launchpad/minify-app-specific-js-592795
Reviewer Review Type Date Requested Status
Māris Fogels (community) Approve
Review via email: mp+27395@code.launchpad.net

Commit message

Ensure JavaScript included from app-specific modules is minified.

Description of the change

This gets js files that live in app-specific javascript directories
minified. They are not currently minified, and while moving bugs js
code to lp.bugs.javascript, I got the build error about launchpad.js
being over 500k.

I've run the fix by rockstar who wrote the original lp-dep script,
and mars since he maintains the front-end build infrastructure. Both
seemed generally fine with the approach here, after some small
discussion on IRC.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  Makefile
  utilities/lp-deps.py

To post a comment you must log in.
Revision history for this message
Māris Fogels (mars) wrote :

Hi Deryck,

I assume the log_none() monkey patch is because this script's output to STDOUT is a programmatic input to another script? It would be nice to put a comment before if that is the case.

I assume you ran this through 'xvfb-run make jscheck'?

And thanks for the Makefile fix.

With the added comment, r=mars.

Maris

review: Approve
Revision history for this message
Deryck Hodge (deryck) wrote :

Hi, Maris.

I'm adding a comment for the monkey patch, and yes, I have run this through make jscheck. Passes fine.

Thanks for the review and comments!

Cheers,
deryck

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2010-06-09 14:49:31 +0000
+++ Makefile 2010-06-14 13:36:38 +0000
@@ -153,7 +153,7 @@
153 -s lib/canonical/launchpad/javascript \153 -s lib/canonical/launchpad/javascript \
154 -b $(LP_BUILT_JS_ROOT) \154 -b $(LP_BUILT_JS_ROOT) \
155 $(shell $(HERE)/utilities/yui-deps.py) \155 $(shell $(HERE)/utilities/yui-deps.py) \
156 $(shell $(HERE)/utilities/lp-deps.py) \156 $(shell $(PY) $(HERE)/utilities/lp-deps.py) \
157 lib/canonical/launchpad/icing/lazr/build/lazr.js157 lib/canonical/launchpad/icing/lazr/build/lazr.js
158 ${SHHH} bin/jssize158 ${SHHH} bin/jssize
159159
160160
=== modified file 'utilities/lp-deps.py'
--- utilities/lp-deps.py 2010-05-18 18:04:00 +0000
+++ utilities/lp-deps.py 2010-06-14 13:36:38 +0000
@@ -13,6 +13,7 @@
1313
14import os14import os
1515
16from lazr.js.build import Builder
1617
17TOP = os.path.abspath(18TOP = os.path.abspath(
18 os.path.join(os.path.dirname(__file__), '..'))19 os.path.join(os.path.dirname(__file__), '..'))
@@ -26,13 +27,27 @@
26ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')27ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')
27ICING_BUILD = os.path.join(ICING_ROOT, 'build')28ICING_BUILD = os.path.join(ICING_ROOT, 'build')
2829
30# Builder has lots of logging, which might not
31# play well with printing filenames. Monkey patch
32# to disable it.
33def log_none(msg):
34 return
35
29for DIRSET in JS_DIRSET:36for DIRSET in JS_DIRSET:
30 full_dir = os.path.join(TOP, DIRSET[0])37 full_dir = os.path.join(TOP, DIRSET[0])
38 module_name = DIRSET[1]
39 BUILD_DIR = os.path.join(ICING_BUILD, module_name)
40 if not os.path.exists(BUILD_DIR):
41 os.mkdir(BUILD_DIR)
42 builder = Builder(
43 name=module_name, src_dir=full_dir, build_dir=ICING_BUILD)
44 builder.log = log_none
31 # We don't want the tests to be included. If we want to nest the files in45 # We don't want the tests to be included. If we want to nest the files in
32 # more folders though, this is where we change it.46 # more folders though, this is where we change it.
33 for filename in os.listdir(full_dir):47 for filename in os.listdir(full_dir):
34 if filename.endswith('.js'):48 if filename.endswith('.js'):
49 basename, nothing = filename.split('.js')
50 min_filename = basename + '-min.js'
35 absolute_filename = os.path.join(full_dir, filename)51 absolute_filename = os.path.join(full_dir, filename)
36 print absolute_filename52 builder.link_and_minify(builder.name, absolute_filename)
3753 print os.path.join(BUILD_DIR, min_filename)
38 os.symlink(full_dir, os.path.join(ICING_BUILD, DIRSET[1]))