From e3b6ee05fa9a12f99650d42cc15f7bd5a46ca086 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 7 Feb 2017 15:36:28 -0500 Subject: [PATCH] tools/gen-index: Generate getters LoVullo dropped support for IE<9, so getters can now be used to lazy-load modules. This also means that, during the transition from LoVullo's internal rating-fw repo to liza, and broken require paths (program/, mainly) will not cause problems unless the module containing those requires is explicitly requested. * tools/gen-index.js: Generate getters. --- tools/gen-index | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gen-index b/tools/gen-index index 85a3d11..84abf0b 100755 --- a/tools/gen-index +++ b/tools/gen-index @@ -40,7 +40,7 @@ for module in "$destpath"/!(index).js; do echo , fi - echo -n " '$modname': require( './$modname' )" + echo -n " get '$modname'() { return require( './$modname' ); }" done # include index.js for any sub-directories (namespace) @@ -52,7 +52,7 @@ for dir in $( find "$destpath" -maxdepth 1 -mindepth 1 -type d ); do echo , fi - echo -n " '$ns': require( './$ns' )" + echo -n " get '$ns'() { return require('./$ns'); }" done echo -e "\n};"