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

Export ECMAScript modules (ESM) #71

Open
dretsa opened this issue Oct 8, 2024 · 1 comment
Open

Export ECMAScript modules (ESM) #71

dretsa opened this issue Oct 8, 2024 · 1 comment

Comments

@dretsa
Copy link

dretsa commented Oct 8, 2024

While CJS continues to be an important part of the NodeJS world, it seems to be slowly moving towards ESM. I think we should export both cjs and ems.

The reason for this is so that libraries using negotiator like tinyhttp can be fully ESM. I am happy to help with a PR :)

@dretsa
Copy link
Author

dretsa commented Oct 8, 2024

I have created a new repository for an ESM/TS version of this package. Let me know what you think: https://github.com/colorninja/navigator-es

The branch is called ts-esm-port

Changed:

  • Included lockfile (package-lock was ignored)
  • Added TypeScript
  • Changed package type to module
  • Ported to TS
  • Ensured exported types are the same or better than @types/negotiator
  • Ensured exports are the same (default and named)
  • Migrated tests to built-in node test module (reduce dependencies)
    • very easy because already using assert built-in module

Remaining to do:

  • Add backwards compatibility for CJS
  • Ensure package will be published with correct files
  • Improve TS types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant