[K/JS] Make available transitive reexport for ES modules
This commit is contained in:
+3
-2
@@ -139,8 +139,9 @@ internal fun CrossModuleReferences.crossModuleReferencesHashForIC() = HashCalcul
|
||||
update(importedModule.relativeRequirePath ?: "")
|
||||
}
|
||||
|
||||
updateForEach(transitiveJsExportFrom) { exportFrom ->
|
||||
update(exportFrom.toString())
|
||||
updateForEach(transitiveJsExportFrom) { transitiveExport ->
|
||||
update(transitiveExport.internalName.toString())
|
||||
update(transitiveExport.externalName)
|
||||
}
|
||||
|
||||
updateForEach(exports.keys.sorted()) { tag ->
|
||||
|
||||
+4
-2
@@ -161,7 +161,7 @@ private class JsIrModuleCrossModuleReferecenceBuilder(
|
||||
}
|
||||
|
||||
val transitiveExport = transitiveJsExportFrom.mapNotNull {
|
||||
if (it.hasJsExports) import(it) else null
|
||||
if (!it.hasJsExports) null else CrossModuleTransitiveExport(import(it), it.externalModuleName)
|
||||
}
|
||||
return CrossModuleReferences(
|
||||
moduleKind,
|
||||
@@ -190,10 +190,12 @@ private class JsIrModuleCrossModuleReferecenceBuilder(
|
||||
|
||||
class CrossModuleImport(val exportedAs: String, val moduleExporter: JsName)
|
||||
|
||||
class CrossModuleTransitiveExport(val internalName: JsName, val externalName: String)
|
||||
|
||||
class CrossModuleReferences(
|
||||
val moduleKind: ModuleKind,
|
||||
val importedModules: List<JsImportedModule>, // additional Kotlin imported modules
|
||||
val transitiveJsExportFrom: List<JsName>, // the list of modules which provide their js exports for transitive export
|
||||
val transitiveJsExportFrom: List<CrossModuleTransitiveExport>, // the list of modules which provide their js exports for transitive export
|
||||
val exports: Map<String, String>, // tag -> index
|
||||
val imports: Map<String, CrossModuleImport>, // tag -> import statement
|
||||
) {
|
||||
|
||||
+14
-4
@@ -173,10 +173,20 @@ class Merger(
|
||||
}
|
||||
|
||||
private fun transitiveJsExport(): List<JsStatement> {
|
||||
val internalModuleName = ReservedJsNames.makeInternalModuleName()
|
||||
val exporterName = ReservedJsNames.makeJsExporterName()
|
||||
return crossModuleReferences.transitiveJsExportFrom.map {
|
||||
JsInvocation(JsNameRef(exporterName, it.makeRef()), internalModuleName.makeRef()).makeStmt()
|
||||
return if (isEsModules) {
|
||||
crossModuleReferences.transitiveJsExportFrom.map {
|
||||
JsExport(JsExport.Subject.All, it.externalName)
|
||||
}
|
||||
} else {
|
||||
val internalModuleName = ReservedJsNames.makeInternalModuleName()
|
||||
val exporterName = ReservedJsNames.makeJsExporterName()
|
||||
|
||||
crossModuleReferences.transitiveJsExportFrom.map {
|
||||
JsInvocation(
|
||||
JsNameRef(exporterName, it.internalName.makeRef()),
|
||||
internalModuleName.makeRef()
|
||||
).makeStmt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user