Skip to content

[2.1.x] Migrate from CommonJS (CJS) to ECMAScript Modules (ESM) #37

Description

@Tommytrg

We need to transition our codebase from CommonJS (CJS) to ECMAScript Modules (ESM) to align with modern JavaScript standards, improve compatibility with the latest Node.js versions, and enable better tree-shaking for optimized builds.

  • Update package.json to "type": "module" (or adjust file extensions accordingly).
  • Refactor all require statements to import syntax.
  • Update module.exports to export syntax.
  • Identify and resolve any dependencies that don’t support ESM.
  • Update build and testing configurations if necessary.
  • Verify that all scripts and tools (e.g., bundlers, linters) work correctly with ESM.

Additional Context

  • If we need dual support (CJS + ESM), we may consider using "exports" field in package.json.
  • Some dependencies may still require dynamic imports (import() instead of require).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions