Allow to specify an objectToExportTo for goog.exportSymbol

This allows users to build ol3 without anything exposed in the
global namespace. This can e.g. be useful for creating an ol3
AMD module, by simply using a build configuration with
"define('ol',function(){var o={};%output%return o.ol;});" as
"output_wrapper".
This commit is contained in:
Andreas Hocevar
2014-05-20 21:49:26 +02:00
parent 6185005c3f
commit cd4092f3e0
2 changed files with 26 additions and 11 deletions

View File

@@ -27,6 +27,10 @@ function assertValidConfig(config, callback) {
callback(new Error('Config missing "exports" array'));
return;
}
if (config.namespace && typeof config.namespace !== 'string') {
callback(new Error('Config "namespace" must be a string'));
return;
}
if (config.compile && typeof config.compile !== 'object') {
callback(new Error('Config "compile" must be an object'));
return;
@@ -182,7 +186,7 @@ function build(config, paths, callback) {
function main(config, callback) {
async.waterfall([
assertValidConfig.bind(null, config),
generateExports.bind(null, config.exports),
generateExports.bind(null, config.exports, config.namespace),
getDependencies.bind(null, config.src),
build.bind(null, config)
], callback);