Skip to content

Convert project to ESM + type module #4876

@techsmyth

Description

@techsmyth

Description

As a developer I want to be able to use the latest packages.

Part of Phase 3 of Epic alkem-io/alkemio#1536. Should be deferred until NestJS 12 ships native ESM support (~Q3 2026).

Acceptance criteria

  • Wait for NestJS 12 stable release with native ESM support
  • Migrate tsconfig module from commonjs to ESM output
  • Add "type": "module" to package.json
  • Update moduleResolution to node16 or nodenext
  • Use full relative file paths for imports (e.g., ./index.js)
  • Use the node: protocol for Node.js built-in imports
  • Replace graphql-upload@13 with ESM-compatible alternative (graphql-upload-ts or graphql-upload@17)
  • Wrap TypeORM entity relations with Relation type to avoid circular dependency issues
  • Audit and update all ESM-only / CJS-only dependencies
  • Update build scripts and Dockerfile CMD if needed
  • All existing tests pass

Additional Context

NestJS 12 (~Q3 2026) will make ESM the default module system. Key challenges:

  • graphql-upload v14+ is ESM-only — current v13 is CJS
  • TypeORM circular dependencies need Relation wrapper in ESM
  • Some packages (chalk, node-fetch, ora, execa) have gone ESM-only in recent versions
  • Node 24's require(esm) helps bridge the gap during transition

References:

Dependencies

  • NestJS 12 stable release
  • Phase 1 (Apollo 5 + NestJS 11) and Phase 2 (Node 24) should be completed first

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions