Class Module


  • public abstract class Module
    extends java.lang.Object
    Information for modules, particularly ES modules, that is useful for rewriting. The primary pieces of information are what variables are exported (transitive or local), and what names are imported.
    • Method Detail

      • path

        @Nullable
        public abstract ModuleLoader.ModulePath path()
        Path of this module. Null if this module is a nested goog.loadModule.
      • namespace

        public abstract com.google.common.collect.ImmutableMap<java.lang.String,​Binding> namespace()
        Map of exported identifiers to originating binding.

        Note that the keys are different than boundNames(). Here the keys are the exported name, not the local name.

        Examples:

        • Locally defined exports (e.g. export let x;, let x; export {x as v}; ) creates an entry with the exported name for the local module's export definition.
        • export default function foo() {}; creates an entry with the name "default" for the local module's default export definition.
        • export {x as v} from 'mod'; creates an entry with the name "v" for the export definition x from 'mod'.
        • import statements make no entries on their own. If imported values are exported with export {}; then an entry is created like export {} from .
        • exports.foo = bar; creates an entry with the name "foo" for the expression on the right-hand side. This is not bound to a local name.
      • boundNames

        public abstract com.google.common.collect.ImmutableMap<java.lang.String,​Binding> boundNames()
        Map of local identifiers to originating binding.

        This includes all names bound by import and exported names which originate in this module. Used for rewriting in later stages of the compiler.

        ES modules may have names bound by both imports and exports. Closure modules only have names bound by imports, as it is impossible to create a new local identifier in an export.

        Examples:

        • import {x as v} from 'mod'; creates an entry with the name "v" for the export definition x from 'mod'.
        • import * as ns from 'mod'; creates an entry with the name "ns" with a binding containing all of mod's bindings.
        • export default function foo() {} creates an entry with the name "foo" for the local module's export definition.
        • export {x as v} from 'mod'; does not create any entry in this module.
        • const C = goog.require('mod.C') creates an entry with the name "C" for the binding containing the default export of 'mod.C'
      • localNameToLocalExport

        public abstract com.google.common.collect.ImmutableMap<java.lang.String,​Export> localNameToLocalExport()
        Map of local identifier name to local export definition.
      • closureNamespace

        @Nullable
        public abstract java.lang.String closureNamespace()
        The specific Closure namespace this module represents, if any. This can be from goog.provide, goog.module, or goog.module.declareNamespace. Null otherwise.
      • builder

        public static Module.Builder builder()
        Creates a new builder.
      • toBuilder

        public abstract Module.Builder toBuilder()
        Returns this module in builder form.