Skip to content

Commit

Permalink
in build-i18n.js, add selective module export and allow underscore im…
Browse files Browse the repository at this point in the history
…porting.
  • Loading branch information
toolness committed Dec 4, 2012
1 parent 9055ecc commit 15ab560
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build-i18n.js
@@ -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'
Expand All @@ -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;
Expand Down

0 comments on commit 15ab560

Please sign in to comment.