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

ES Modules support #32

Open
ramiroaisen opened this issue Dec 19, 2021 · 2 comments
Open

ES Modules support #32

ramiroaisen opened this issue Dec 19, 2021 · 2 comments

Comments

@ramiroaisen
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

With these simple steps you can add ES Modules support.

Here is the diff that solved my problem:

diff --git a/node_modules/rgb2hex/index.js b/node_modules/rgb2hex/index.js
index 3c0f6d7..b013adf 100644
--- a/node_modules/rgb2hex/index.js
+++ b/node_modules/rgb2hex/index.js
@@ -8,7 +8,7 @@
  * @return {Object}        object with hex and alpha value
  */
 
-var rgb2hex = module.exports = function rgb2hex(color) {
+export default function rgb2hex(color) {
     if(typeof color !== 'string') {
         // throw error of input isn't typeof string
         throw new Error('color has to be type of `string`');

This issue body was partially generated by patch-package.

@bjankord
Copy link

Could use an ES module version of this package as I'm planning to use it in the browser.

@christian-bromann
Copy link
Owner

If someone can provide a PR with necessary changes to use this package with CJS and ESM I would be happy to merge and release it. I currently don't have much time to look into this.

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

3 participants