-
-
Notifications
You must be signed in to change notification settings - Fork 220
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
Rework bundler and bring back support to es2017 #1370
Rework bundler and bring back support to es2017 #1370
Conversation
|
@belgattitude is attempting to deploy a commit to the Rooks Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report
@@ Coverage Diff @@
## main #1370 +/- ##
=======================================
Coverage 91.61% 91.61%
=======================================
Files 76 76
Lines 4792 4792
Branches 816 816
=======================================
Hits 4390 4390
Misses 402 402 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
"exports": { | ||
".": { | ||
"types": "./dist/types/index.d.js", | ||
"module": "./dist/esm/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.
Kept the module
for webpack support (it's not part of the final spec). Not sure if recent versions needs that.
Didn't add the browser
field (umd), cause nextjs 12.x will pick it up and defeat tree-shakability (browser bundle should be one file for now)
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.
@belgattitude Could you help me with any reading material for me to fully understand what has changed in the exports
field? It changes so often I lost track of it. For eg, what does what field within exports
do and what everyone else does, etc. Just want to make sure I understand all the changes we are making and we don't accidentally break anything.
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.
Most up-to-date I found out is
https://github.com/frehner/modern-guide-to-packaging-js-library#define-your-exports
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.
If you feel unsure I can cherry-pick this and create another PR.
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.
@belgattitude Thanks for this! I will read this and get back. I will take a good look at this PR tomorrow.
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.
TIL learnt a lot from that link today. Thanks!
|
||
const tsPathPlugin = typescriptPaths({ | ||
preserveExtensions: true, | ||
tsConfigPath: "./tsconfig.json", |
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.
typescriptPaths plugin does not support extend from tsconfig.build.json. So I use the paths from there. Note that it makes use remove composite: true.
Hey @imbhargav5. It's just a start. But I'd like to know
I'm not totally sure about this. Happy week-end. |
Going to look at this tonight! |
@belgattitude |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
If all looks good to you, my plan is to replace the build with build-future and the new rollup config. I'll undraft when done. My last concern, I saw a drop in size in the umd bundle. I guess is that the *.spec.ts aren't treated anymore. But I'd like another look. |
Will take a look. |
@belgattitude Looks like a great start. I am getting errors after I run |
Yes it will check the ./dist/* folder, not the ./dist/future 😄 . I'll P/R tomorrow. |
Hey @imbhargav5 I've just finalized the thing. Added
Entered pre canary mode, so If you don't mind I'd like to test a canary version release first. |
# Conflicts: # packages/rooks/package.json # yarn.lock
Found a little time and fixed conflicts. Ported the check-size in #1365 Good news, the size increase is very minimal The build passed from 20s to 15s on my laptop. Imo it can be merged, let me know if you have questions. Thanks for this beautiful lib |
// @ts-check | ||
|
||
// Regularly update this max size when new hooks are added (keep a threshold) | ||
const fullBundleMaxSize = "12KB"; |
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.
@imbhargav5 just to mention, if enforced on CI and new hooks are added and the total size of lib grow, this should be increased.
On the other side, it's totally possible to keep only the "ESM Webpack ({ useDebounce })"
(see below), that's actually the important check
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.
@belgattitude Ah. I think we could write a small script to autopopulate new hooks into the size-limit file when new hooks are added and keep the limit at 2kb. What do you think?
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.
Nice idea
@@ -7,6 +7,15 @@ | |||
"unpkg": "dist/umd/rooks.umd.js", | |||
"types": "dist/types/index.d.ts", | |||
"typings": "dist/types/index.d.ts", | |||
"exports": { | |||
".": { | |||
"types": "./dist/types/index.d.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.
"types": "./dist/types/index.d.js", | |
"types": "./dist/types/index.d.ts", |
This is such a massive improvement @belgattitude ! I just want to keep this in |
@belgattitude I continued your work here. #1408 |
Purpose
Rework the bundler config to ensure emitted file are valid es2017 files. Will fix #1362
PS: merged as part of #1408
Approach
Tried to keep on rollup, but easily extensible for esbuild
How to try it out
Checks
Impact on size: negligible imo
Tasks