Skip to content

Commit a0accef

Browse files
gkdncopybara-github
authored andcommitted
Introduce a stop gap goog.declareModuleId.
In my testing for rules_closure, it seems like bundled mode was broken for some time (ordering of the modules was incorrect) so this version only works for compiled mode to preserve pre archiving of closure_library state. PiperOrigin-RevId: 718933109
1 parent 04f746a commit a0accef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/base.js

+16
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,22 @@ goog.module.declareLegacyNamespace = function() {
435435
goog.moduleLoaderState_.declareLegacyNamespace = true;
436436
};
437437

438+
/**
439+
* Associates an ES6 module with a Closure module ID so that is available via
440+
* goog.require. The associated ID acts like a goog.module ID - it does not
441+
* create any global names, it is merely available via goog.require /
442+
* goog.module.get / goog.forwardDeclare / goog.requireType. goog.require and
443+
* goog.module.get will return the entire module as if it was import *'d. This
444+
* allows Closure files to reference ES6 modules for the sake of migration.
445+
*
446+
* @param {string} namespace
447+
* @suppress {missingProvide}
448+
*/
449+
goog.declareModuleId = function(namespace) {
450+
if (!COMPILED) {
451+
throw new Error('goog.declareModuleId is not supported in uncompiled mode');
452+
}
453+
};
438454

439455
/**
440456
* Marks that the current file should only be used for testing, and never for

0 commit comments

Comments
 (0)