How do I use non-default exports of ESM? I tried: ...
# javascript
n
How do I use non-default exports of ESM? I tried:
Copy code
@JsModule("@sevenc-nanashi/valuetree-ts")
@JsNonModule
external object ValueTreeTs {
    fun parseValueTree(text: Uint8Array): ValueTree
    fun dumpValueTree(tree: ValueTree): Uint8Array
}
But it generates:
Copy code
import ValueTreeTs from '@sevenc-nanashi/valuetree-ts'
Thus some bundlers complain this.
Copy code
Bundling core...
✘ [ERROR] No matching export in "utaformatix3/build/js/temporary_unbundled/node_modules/@sevenc-nanashi/valuetree-ts/mod.js" for import "default"

    utaformatix3/build/js/temporary_unbundled/kotlin/utaformatix-core-modified.mjs:4:7:
      4 │ import ValueTreeTs from '@sevenc-nanashi/valuetree-ts';
        ╵        ~~~~~~~~~~~

error: Uncaught (in promise) Error: Build failed with 1 error:
utaformatix3/build/js/temporary_unbundled/kotlin/utaformatix-core-modified.mjs:4:7: ERROR: No matching export in "utaformatix3/build/js/temporary_unbundled/node_modules/@sevenc-nanashi/valuetree-ts/mod.js" for import "default"
Are there any good solution? I'd like kotlin to emit:
Copy code
import * as ValueTreeTs from '@sevenc-nanashi/valuetree-ts';
2
Self resolved: I used
@file:JsModule