From a95327f18e6b71b948ed8dd11181a3198638ee85 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 19 Dec 2014 14:41:47 -0700 Subject: [PATCH] Define goog and assign to global When concatenating the Closure Library, base.js creates a new `goog` object if there is not already one in scope. Later, `goog.global` is assigned the value of `this`. Calls to `goog.provide` create "namespace" objects by assigning to `goog.global`. To ensure that `goog` is the same as `goog.global.goog`, we need to create a new `goog` object in the scope of base.js and assign it to `this.goog`. --- tasks/build.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tasks/build.js b/tasks/build.js index 8196acaabe..d89eea0966 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -175,11 +175,14 @@ function concatenate(paths, callback) { var msg = 'Trouble concatenating sources. ' + err.message; callback(new Error(msg)); } else { - var preamble = 'var CLOSURE_NO_DEPS = true;\n'; var parts = umdWrapper.split('%output%'); - var postamble = 'OPENLAYERS.ol = ol;\n'; - callback(null, - preamble + parts[0] + results.join('\n') + postamble + parts[1]); + var src = 'var CLOSURE_NO_DEPS = true;\n' + + parts[0] + + 'var goog = this.goog = {};\n' + + results.join('\n') + + 'OPENLAYERS.ol = ol;\n' + + parts[1]; + callback(null, src); } }); }