Permalink
Browse files

in build-i18n.js, add selective module export and allow underscore im…

…porting.
  • Loading branch information...
1 parent 9055ecc commit 15ab56026b54f813faadeb37386db4903eafa8da @toolness committed Dec 4, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 build-i18n.js
View
@@ -1,3 +1,7 @@
+// If args are specified on the command line, assume they are
+// module names, and only export their localizations.
+var MODULE_FILTER = process.argv.slice(2);
+
var NLS_PATHS = [
'fc/nls',
'slowparse-errors/nls'
@@ -8,13 +12,21 @@ var requirejs = require('requirejs');
var requireConfig = require('./js/require-config');
var bundles = {};
+// For some reason r.js doesn't like our default underscore shim.
+requireConfig.shim['underscore'].exports = '_';
+
requirejs.config(requireConfig);
NLS_PATHS.forEach(function(path) {
fs.readdirSync(__dirname + '/js/' + path).forEach(function(filename) {
var match = filename.match(/^(.*)\.js$/);
if (match) {
var moduleName = path + '/' + match[1];
+
+ if (MODULE_FILTER.length &&
+ MODULE_FILTER.indexOf(moduleName) == -1)
+ return;
+
var bundle = requirejs(moduleName);
bundles[moduleName] = bundle;

0 comments on commit 15ab560

Please sign in to comment.