Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM version #159

Closed
MatthiasKunnen opened this issue May 23, 2021 · 1 comment · Fixed by #163
Closed

ESM version #159

MatthiasKunnen opened this issue May 23, 2021 · 1 comment · Fixed by #163

Comments

@MatthiasKunnen
Copy link

MatthiasKunnen commented May 23, 2021

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.

@theoludwig
Copy link

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
Labels
None yet
Projects
None yet
2 participants