From 6dae6c4f825093a34aa3f3911c63207a8f447ac1 Mon Sep 17 00:00:00 2001 From: Alec Merdler Date: Wed, 2 Aug 2017 11:26:36 -0400 Subject: [PATCH] whitelisted moment.js locales to reduce bundle size --- endpoints/common.py | 11 ++++------- static/js/quay-config.module.ts | 1 + static/js/services/user-service.js | 3 +++ templates/base.html | 12 ------------ test/data/test.db | Bin 1687552 -> 1679360 bytes webpack.config.js | 5 +++++ 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/endpoints/common.py b/endpoints/common.py index 1693c5762..7e1625c71 100644 --- a/endpoints/common.py +++ b/endpoints/common.py @@ -24,6 +24,9 @@ from _init import __version__ logger = logging.getLogger(__name__) +JS_BUNDLE_NAME = 'bundle' + + def common_login(user_uuid, permanent_session=True): """ Performs login of the given user, with optional non-permanence on the session. """ user = model.get_user(user_uuid) @@ -71,10 +74,7 @@ def _list_files(path, extension, contains=""): def render_page_template(name, route_data=None, **kwargs): """ Renders the page template with the given name as the response and returns its contents. """ - library_styles = [] - main_styles = [] - library_scripts = [] - main_scripts = _list_files('build', 'js', "bundle") + main_scripts = _list_files('build', 'js', JS_BUNDLE_NAME) use_cdn = app.config.get('USE_CDN', True) if request.args.get('use_cdn') is not None: @@ -118,10 +118,7 @@ def render_page_template(name, route_data=None, **kwargs): route_data=route_data, external_styles=external_styles, external_scripts=external_scripts, - main_styles=main_styles, - library_styles=library_styles, main_scripts=main_scripts, - library_scripts=library_scripts, feature_set=features.get_features(), config_set=frontend_visible_config(app.config), oauth_set=get_oauth_config(), diff --git a/static/js/quay-config.module.ts b/static/js/quay-config.module.ts index 171f2e0b9..7ef10b3cb 100644 --- a/static/js/quay-config.module.ts +++ b/static/js/quay-config.module.ts @@ -4,6 +4,7 @@ import { NAME_PATTERNS } from "./constants/name-patterns.constant"; import * as Raven from "raven-js"; + var quayDependencies: string[] = [ 'chieffancypants.loadingBar', 'cfp.hotkeys', diff --git a/static/js/services/user-service.js b/static/js/services/user-service.js index d9bc0f9a0..faaebcea0 100644 --- a/static/js/services/user-service.js +++ b/static/js/services/user-service.js @@ -1,3 +1,6 @@ +import * as Raven from 'raven-js'; + + /** * Service which monitors the current user session and provides methods for returning information * about the user. diff --git a/templates/base.html b/templates/base.html index 213725d92..5cb29deed 100644 --- a/templates/base.html +++ b/templates/base.html @@ -22,14 +22,6 @@ - {% for style_path in main_styles %} - - {% endfor %} - - {% for style_path in library_styles %} - - {% endfor %} - {% block added_stylesheets %} {% endblock %} @@ -57,10 +49,6 @@ {% endfor %} - {% for script_path in library_scripts %} - - {% endfor %} - {% block added_dependencies %} {% endblock %} diff --git a/test/data/test.db b/test/data/test.db index 15c7fad71b1638a7c018b213e63c7be43ededfde..e109172d6a86edc69ff686a6a5063c939d785ec6 100644 GIT binary patch delta 506 zcmYk&K}Z`x6b9g#w@KH{?&hhnYGSP0U_k{XwzStMl;X{x6nb+Hi4wFVbqgXYtf*Mq zw2c%QP!I7USS1ERnM)3W-dc+ES}3C6sR!?h^lj5a4<9qU|IK?at~=o#jThSd$BgmK zbt^%a-pjyZY9+}}UAQOv zUHGcgwr}F*9q8is2WXN%^U&?JoCvi5y>g%cC$*Nd5_HImZMgq$KoKnYs0hbi`a@O^ zV8{#J2(|15WmxipU;db%4{~vI0MXUGDiDSEh@adcDybtH2@qZGRgD)HI(;MRF@_}^ zmqyXdYZc3W%VlieeCq3b1{%}Cy#KjY=VV^yrqVF__pqkZxvZ0Uot>WT6Stqu&ehVP aNrD7PJ!v3~Bt)9XUD8ZiWa+SV#3da1c5TP8vkjL}scL1t z$xPmF-pp@)@6GJQ!=Z_Z;p=S;KbuU{+^1webbQTAlZlxG^<4tZd72tb;K55;JBOFl zmS*!G_+{#58x8*9n3LENi4{b&nTe)*}@ zLL8*QOi>Px-n#YHrMFJKZBxYk=qn4sgC?c<7;3{gEa4PRK)AQ?ARbfP&6Gp!c?H?A zA}mnbl(C~|)=cne#d-|+T1R0EX*`V2;?wx9zL9I+w(y&DEKv$)&{YV1)TA`sZ*|$1 z@CZN!{5AwWs&40ztF%YuwJxe%xg?{H%!J*kSTiWZvfs1curursdyw4;5g#!{x4D-J z__;`@KicW%2>Px4#&7aEEMsDqrpgUw`aB6-yI8ud_jL8 z6bZZQ-Mb-jED-Poy8~RP+Xe2u<;6?UA#_w*JQ(ioj&RQU>0B%jj0M8JXgK1J1l!zZ zrT0tZd{96ZvzahY73&0YGjr_wY@F?3oy=3UeFFW+D2ua*DH^i#SZo#chV%^lHT+ij z>j+l;VZR~6DxmDIqp1A;G4iOt&7xhvkhLh*>!@=hNI1u?)DfbYo_b?R^#U}_mVoCc6u&W<)6qCC8ZoLBEGA}}+U1*`$=1u!dE zBbW`024mDai|onA3?4FJ+YJ+*x7|?LTlQI7amtEllWhw%!wuRRbE%O`T0|Wk$HiPe zB@L6Tn2~d-yqvw<(LvLPgi&GOTsD=-(>%|ghf%IHf@yL#PsYjXvP=qOC@YVU9lox! zLUzXFrf^d6Bc25KC&NWJ&WGCqZ1&e!#S< zeq35h{+uqv~lNmnwN5msTdeHhN~}$EAWENsFszzdq8_ zAI^R`|Kn1r0E$`#EKksiKp$v18kh7c&{lnR8I(~g>j38K6|x-t2-E@$YKq~IUJc&D z)Szcs&r=mWjjrBx(=#qT4@HYS|2!3~++;>l>Pi;1V$^m3fBrEM%NkxOxas}nyJu!s zy@)Fx$Nxpto}<4Nai}7qQN>ga`?#x8Fw-Y$&${|mrF~TWx6gWw6P!HngcIDWKb2GF a+9Ry}2wTS^T)(GMFLM1Z#Wi0R-ojtw9(bSt diff --git a/webpack.config.js b/webpack.config.js index 35fd72fa0..6944a3a64 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,6 +17,8 @@ let config = { externals: { angular: "angular", jquery: "$", + moment: "moment", + "raven-js": "Raven", }, module: { rules: [ @@ -47,7 +49,10 @@ let config = { FileSaver: 'file-saver', angular: "angular", $: "jquery", + moment: "moment", }), + // Restrict the extra locales that moment.js can load; en is always included + new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/), ], devtool: "cheap-module-source-map", };