code: private void findModulesFromInput(
        CompilerInput input,
        boolean wasImportedByModule,
        Set<CompilerInput> inputs,
        Map<String, CompilerInput> inputsByIdentifier,
        Map<String, CompilerInput> inputsByProvide,
        boolean supportEs6Modules,
        boolean supportCommonJSModules) {
      if (!inputs.remove(input)) {
        // It's possible for a module to be included as both a script
        // and a module in the same compilation. In these cases, it should
        // be forced to be a module.
        if (wasImportedByModule && input.getJsModuleType() == CompilerInput.ModuleType.NONE) {
          input.setJsModuleType(CompilerInput.ModuleType.IMPORTED_SCRIPT);
        }
        return;
      }
  
      FindModuleDependencies findDeps =
          new FindModuleDependencies(
              this, supportEs6Modules, supportCommonJSModules, inputPathByWebpackId);
      findDeps.process(checkNotNull(input.getAstRoot(this)));
  
      // If this input was imported by another module, it is itself a module
      // so we force it to be detected as such.
      if (wasImportedByModule && input.getJsModuleType() == CompilerInput.ModuleType.NONE) {
        input.setJsModuleType(CompilerInput.ModuleType.IMPORTED_SCRIPT);
      }
      this.moduleTypesByName.put(input.getPath().toModuleName(), input.getJsModuleType());
  
      Iterable<String> allDeps =
          Iterables.concat(
              input.getRequiredSymbols(), input.getDynamicRequires(), input.getTypeRequires());
      for (String requiredNamespace : allDeps) {
        CompilerInput requiredInput = null;
        boolean requiredByModuleImport = false;
        if (inputsByProvide.containsKey(requiredNamespace)) {
          requiredInput = inputsByProvide.get(requiredNamespace);
        } else if (inputsByIdentifier.containsKey(requiredNamespace)) {
          requiredByModuleImport = true;
          requiredInput = inputsByIdentifier.get(requiredNamespace);
        }
  
        if (requiredInput != null) {
          findModulesFromInput(
              requiredInput,
              requiredByModuleImport,
              inputs,
              inputsByIdentifier,
              inputsByProvide,
              supportEs6Modules,
              supportCommonJSModules);
        }
      }
    }
docs: Traverse an input's dependencies to find additional modules.