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

ES6 modules #171

Open
tyteen4a03 opened this issue Apr 15, 2021 · 6 comments
Open

ES6 modules #171

tyteen4a03 opened this issue Apr 15, 2021 · 6 comments

Comments

@tyteen4a03
Copy link

Hi, are there any plans to migrate this module to ES6 modules?

@blakeembrey
Copy link
Collaborator

Not for the foreseeable future, no.

@jarrodek
Copy link

jarrodek commented May 8, 2021

Hey @blakeembrey would you accept a PR with an ES6 module for this library? Bundles widely support ESM so it doesn't make much of a difference for them. For a direct use (including in a web app to a global scope), well, with a breaking change devs have minimal work to do to upgrade to a new major version.

@blakeembrey
Copy link
Collaborator

I'd probably release it alongside a rewrite of the library. The main thing I don't want to be doing is maintaining two versions or breaking existing node use-cases. Since all supported node versions now have ESM support, it should be easier, but it's still hard for people to migrate.

@capaj
Copy link

capaj commented Jun 9, 2021

but it's still hard for people to migrate.

why would they need to migrate?
If you add a module entry point to package.json and add pluralize.esm.js it will satisfy both ES6 and legacy consumers.

Of course it requires adding a build step, but that's trivial with microbundle or similar.

@friday
Copy link

friday commented Jun 23, 2021

You don't need to refactor, but you do need a build/bundle step. Just delete your module wrapper code and use rollup or something similar to bundle different versions. Reference those in package.json main, module (and web if you minify). You probably want to gitignore the folder you put them in.

The output from rollup is very clean.

@wegry wegry mentioned this issue Aug 24, 2021
@silverwind
Copy link

I'd be nice if the CJS exports of this module would be statically analyzeable, so things like https://github.com/nodejs/cjs-module-lexer can provide named exports when importing it in ESM.

If it would assign it's exported to module.exports, it will work in all environments. Stuff like AMD or globals (ugh) are no longer necessary in the modern JS world.

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

6 participants