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

fix: commonjs bundle compat with esm #18

Merged
merged 1 commit into from
Jan 10, 2023
Merged

fix: commonjs bundle compat with esm #18

merged 1 commit into from
Jan 10, 2023

Conversation

dangreen
Copy link
Contributor

@dangreen dangreen commented Jan 8, 2023

@dangreen
Copy link
Contributor Author

dangreen commented Jan 9, 2023

@kurkle please review 🙏

Copy link
Owner

@kurkle kurkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the output different compared to using index.esm as entry for the umd build?

What issue is this solving?

@dangreen
Copy link
Contributor Author

dangreen commented Jan 9, 2023

@kurkle ESM bundle provides named exports, the CommonJS bundle - does not. In this PR, I added named exports to the CommonJS Bundle.

@kurkle
Copy link
Owner

kurkle commented Jan 9, 2023

And is the default export compatible too? To me it looks like this new one will be just a recursive object?

@dangreen
Copy link
Contributor Author

dangreen commented Jan 9, 2023

@kurkle yes

> const color = require('.')
undefined
> color
<ref *1> [Function: index_esm] {
  Color: [class Color],
  default: [Circular *1],
  round: [Function: round],
  lim: [Function: lim],
  p2b: [Function: p2b],
  b2p: [Function: b2p],
  n2b: [Function: n2b],
  b2n: [Function: b2n],
  n2p: [Function: n2p],
  hexParse: [Function: hexParse],
  hexString: [Function: hexString],
  rgb2hsl: [Function: rgb2hsl],
  hsl2rgb: [Function: hsl2rgb],
  hwb2rgb: [Function: hwb2rgb],
  hsv2rgb: [Function: hsv2rgb],
  hueParse: [Function: hueParse],
  rotate: [Function: rotate],
  hslString: [Function: hslString],
  nameParse: [Function: nameParse],
  rgbParse: [Function: rgbParse],
  rgbString: [Function: rgbString]
}
> color('white')
Color { _rgb: { r: 255, g: 255, b: 255, a: 255 }, _valid: true }
> new color.Color('white')
Color { _rgb: { r: 255, g: 255, b: 255, a: 255 }, _valid: true }
> 

"default" export is a function with assigned properites

@kurkle kurkle added the bug Something isn't working label Jan 10, 2023
@kurkle kurkle merged commit d0e6c81 into kurkle:master Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helpers.segment.cjs incorrectly handle CommonJS import from @kurkle/color
2 participants