[K2 JS] Do not load transitive dependencies for building K2/JS klibs

^KT-57262 Fixed
This commit is contained in:
Alexander Korepanov
2023-03-13 12:31:56 +01:00
committed by Space Team
parent 62fb3df7f0
commit e3402fcc87
14 changed files with 94 additions and 34 deletions
@@ -78,7 +78,7 @@ fun compileModuleToAnalyzedFir(
// TODO: !!! dependencies module data?
}
val resolvedLibraries = moduleStructure.fullResolvedLibraries
val resolvedLibraries = moduleStructure.allDependencies
val sessionsWithSources = prepareJsSessions(
ktFiles, moduleStructure.compilerConfiguration, escapedMainModuleName,
@@ -106,11 +106,11 @@ fun transformFirToIr(
var builtInsModule: KotlinBuiltIns? = null
val dependencies = mutableListOf<ModuleDescriptorImpl>()
val librariesDescriptors = moduleStructure.fullResolvedLibraries.map { resolvedLibrary ->
val librariesDescriptors = moduleStructure.allDependencies.map { resolvedLibrary ->
val storageManager = LockBasedStorageManager("ModulesStructure")
val moduleDescriptor = JsFactories.DefaultDeserializedDescriptorFactory.createDescriptorOptionalBuiltIns(
resolvedLibrary.library,
resolvedLibrary,
moduleStructure.compilerConfiguration.languageVersionSettings,
storageManager,
builtInsModule,
@@ -120,7 +120,7 @@ fun transformFirToIr(
dependencies += moduleDescriptor
moduleDescriptor.setDependencies(ArrayList(dependencies))
val isBuiltIns = resolvedLibrary.library.unresolvedDependencies.isEmpty()
val isBuiltIns = resolvedLibrary.unresolvedDependencies.isEmpty()
if (isBuiltIns) builtInsModule = moduleDescriptor.builtIns
moduleDescriptor
@@ -170,7 +170,7 @@ fun serializeFirKlib(
moduleStructure.compilerConfiguration.get(IrMessageLogger.IR_MESSAGE_LOGGER) ?: IrMessageLogger.None,
sourceFiles,
klibPath = outputKlibPath,
moduleStructure.fullResolvedLibraries.map { it.library },
moduleStructure.allDependencies,
irResult.irModuleFragment,
expectDescriptorToSymbol = mutableMapOf(),
cleanFiles = icData,
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.session.*
import org.jetbrains.kotlin.fir.session.environment.AbstractProjectEnvironment
import org.jetbrains.kotlin.fir.session.environment.AbstractProjectFileSearchScope
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.metadata.resolver.KotlinResolvedLibrary
import org.jetbrains.kotlin.load.kotlin.PackageAndMetadataPartProvider
import org.jetbrains.kotlin.name.Name
@@ -110,7 +111,7 @@ fun <F> prepareJsSessions(
files: List<F>,
configuration: CompilerConfiguration,
rootModuleName: Name,
resolvedLibraries: List<KotlinResolvedLibrary>,
resolvedLibraries: List<KotlinLibrary>,
libraryList: DependencyListForCliModule,
extensionRegistrars: List<FirExtensionRegistrar>,
isCommonSource: (F) -> Boolean,