mirror of
https://github.com/google/blockly.git
synced 2026-01-12 03:17:09 +01:00
fix(closure): Make safe to import in node.js
Make the implementation declareModlueId safe to import and execute in node.js, which does not provide a window global. (N.B. because this is an ESM and therefore automatically strict, using window?.goog?.declareModuleId doesn't work because window being undefined is an early error.)
This commit is contained in:
@@ -72,9 +72,9 @@ export const global = globalThis;
|
||||
// export const scope = goog.scope;
|
||||
// export const defineClass = goog.defineClass;
|
||||
export const declareModuleId = function(namespace) {
|
||||
if (window.goog && window.goog.declareModuleId) {
|
||||
window.goog.declareModuleId.call(this, namespace);
|
||||
}
|
||||
// Use globalThis instead of window to find goog, so this can be
|
||||
// imported in node.js (e.g. when running buildShims gulp task).
|
||||
globalThis?.goog?.declareModuleId.call(this, namespace);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user