# \`@JsExport object\` with ES-modules

**URL:** <https://discuss.kotlinlang.org/t/jsexport-object-with-es-modules/28106>\
**Category:** JavaScript\
**Created:** [February 7, 2024, 11:31pm UTC](https://discuss.kotlinlang.org/t/jsexport-object-with-es-modules/28106 "2024-02-07T23:31:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcwhite](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@bcwhite](https://discuss.kotlinlang.org/u/bcwhite)\
**Post date:** [February 7, 2024, 11:31pm UTC](https://discuss.kotlinlang.org/t/jsexport-object-with-es-modules/28106/1 "2024-02-07T23:31:14Z")

</div>

I’m in the process of trying to [switch to ES-modules](https://kotlinlang.org/docs/whatsnew19.html#experimental-support-for-es6-classes-and-modules) for a common library that is used by my Angular application.

```auto
package com.mydomain.myproj.common
@JsExport
object GlobalConstants {
    const val VERSION = "0.64.0"
}

```

I previously accessed such transpiled code like this:

```auto
import * as myproj_top from "myproj";
import myproj_common = myproj_top.com.mydomain.myproj.common;
import GlobalConstants = myproj_common.GlobalConstants;

```

Ugly, but it works, and I could use it in my code like `GlobalConstants.VERSION` to get the value.

With `useEsModules()`, I don’t have to go through all those import hoops. This works as expected:

```auto
import { GlobalConstants } from "myproj";

```

However, I cannot **use** that imported object the same way. Instead of `GlobalConstants.VERSION`, it seems I need to write `GlobalConstants.getInstance().VERSION`.

_Is this expected or am I just missing something obvious?_
