Hi all. this question might not be 100% kotlin, b...
# javascript
x
Hi all. this question might not be 100% kotlin, but a question of interop between kotlin and typescript in my kotlin-js module, i have a package say
com.organisation.product.core
which has this kotlin class
Copy code
@JSExport
class Service()
once exported with
npm-publish
- when importing this from a typescript project it looks like
Copy code
import {com} from "@organisation/core";
const Service = com.organisation.product.core.Service;
This kinda woks, but when you have another module (for example,
com.organisation.product.feature
) they both end up sharing the
com
Copy code
import {com} from "@organisation/core";
import {com} from "@organisation/feature"; // not allowed
I know you can get around this with alias like
Copy code
import {au as core} from "@organisation/core";
import {au as feature} from "@organisation/feature";

const Service = core.organisation.product.core.Service;
const FeatureService = login.organisation.product.feature.Service;
Is there a way to make these imports much nicer without losing my package structure from kotlin side?
e
in principle I think
Copy code
import {com: {organization: {product: {core}}}} from "@organization/core"
import {com: {organization: {product: {feature}}}} from "@organization/feature"
const com = {organization: {product: {core, feature}}}
would work but that may be too cumbersome
r
There's also several youtrack issues for top level exports and more control over JS exports. I'm not sure what the timeline is and don't have links, but at least you can watch and upvote them.
Also you can remove redundant package via webpack
library.export
option