Skip to content

ESM version #159

Closed
Closed

Description

@MatthiasKunnen

Currently, ms is written in CommonJS. This has some drawbacks:

  • They cannot be treeshaken properly resulting in larger bundles [1]
  • It requires esModuleInterop for TypeScript [2]
  • They are not in the ECMAScript spec as opposed to ESModules [3][4] for which support is being built into browsers[4] and Node[5]

What I propose is to use the main and module field in package.json to provide both ESM and CommonJS. This change is fully backwards compatible and can be achieved by using TypeScript, Webpack, or Rollup. I'd propose to go the TypeScript way which has the added benefit of type safety and allows ms to bundle types.

If you would accept this I could make a PR.

Activity

  1. theoludwig commented on Jul 24, 2021

    @theoludwig

    Great suggestion!:+1:

    I would suggest that we rewrite the package in TypeScript, so we can include types declarations builtin and deprecate @types/ms.

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