-
Notifications
You must be signed in to change notification settings - Fork 507
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:
|
f793fdc
to
6c5ed2a
Compare
6c5ed2a
to
f1d38a8
Compare
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/button@3.141.2-alpha.0 |
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 |
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/button@3.141.1-alpha.1
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