[bug] Modules from `adf-utils` cannot be imported in a TypeScript project

Hello!

We are trying to use adf-utils in our TypeScript project. Importing any module fails. For example, if we try to import traverse, there is this error:

import { traverse } from '@atlaskit/adf-utils';
// import { traverse } from '@atlaskit/adf-utils/traverse.es';
// import { traverse } from '@atlaskit/adf-utils/traverse.js';


-----
  ↓
     

error TS2305: Module '"@atlaskit/adf-utils"' has no exported member 'traverse'.

1 import { traverse } from '@atlaskit/adf-utils';
           ~~~~~~~~


Found 1 error in src/index.ts:1

It seems I cannot attach a zip file here, so I created a GitHub repo to demonstrate the issue: GitHub - ipeychev/test-adf-utils

Here is how to reproduce the error:

  1. Download/clone the repo
  2. Install the dependencies
    $ npm i
  3. Execute the build process
    $ npm run build

Note:

Tried with different variants of loading traverse, from here:

import { traverse } from '@atlaskit/adf-utils';

or

import { traverse } from '@atlaskit/adf-utils/traverse.es';

or

import { traverse } from '@atlaskit/adf-utils/traverse.js';

None of them worked.

Hello Atlassian Development Team,

The problem is that the package.json file that is published to npm is missing the exports field. This is a critical issue because the exports field is the standard way to define the public API of a package and to ensure that it can be correctly resolved by Node.js and TypeScript.

The exports field is present in the source package.json file here, but it is being stripped out or not being correctly transformed during the build process. The published package.json only contains the non-standard af:exports field, which is not understood by standard tooling.

This bug makes it impossible to use the @atlaskit/adf-utils package in a project that uses ES modules. When attempting to import from the package, Node.js throws an ERR_UNSUPPORTED_DIR_IMPORT error.

To fix this bug, you need to update your build process to ensure that the exports field is correctly included in the published package.json and that it points to the correct files in the dist directory.

Thank you for your time and for listening to the community.