-
Notifications
You must be signed in to change notification settings - Fork 508
feat: publish clay as both CJS and ESM #6110
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
base: master
Are you sure you want to change the base?
Conversation
fcc36cd
to
93afc2a
Compare
properties: ['data-testid'], | ||
}, | ||
], | ||
'babel-plugin-fully-specified', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to update any import like from './language-helpers'
, which would resolve to ./language-helpers/index.js
or ./language-helpers.js
.
In ESM, you have to explicitly specify the file and extension, in CJS you don't have to.
"engines": { | ||
"node": ">=0.12.0", | ||
"npm": ">=3.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this, the numbers are wildly off too
"main": "lib/cjs/index.js", | ||
"module": "lib/esm/index.js", | ||
"exports": { | ||
"import": "./lib/esm/index.js", | ||
"require": "./lib/cjs/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all standards with package.json now and allows for both ESM and CJS consumption
Just to note, these are the size differences(in bytes)
|
Oh nice! That's great to see that esm is smaller. Also, I noticed that in the deploy proview logs it looks like there's still a problem with at least one export:
|
f1d38a8
to
586dfaa
Compare
@ethib137 got it passing, has some issues with deeply imported items( |
New build, 3.141.2-alpha.0, https://app.unpkg.com/@clayui/[email protected] |
I tested this in DXP using our build reports, very promising for bundle size by moving to ESM. Note, these are not the gzipped size
|
I think this is worth releasing and testing a new official publish |
Those are pretty great numbers. Do you think there is any risk that including ESM could cause any issues in Portal? If so, I'd say we should wait to release this until after the cut of master for the Q3 release. |
@ethib137 yeah that sounds good to me. I will just keep this here until I am back from PTO and hopefully by then the release is official and cut |
586dfaa
to
0bcd417
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Now that DXP is ESM, we would benefit from also publishing clay as ESM. I am gonna leave this as a draft and publish a prerelease to test in dxp
Check a prerelease here, https://app.unpkg.com/@clayui/[email protected]
I tested button in DXP and saw that with ESM we go from 430 lines of code to 274 for @clayui/button import. So that is promising