update node-fetch to v3 - #856
Conversation
|
Thanks for putting this together! I'm asking the team to review this. |
Cool 👍 Do you know what would be even cooler? Shipping this SDK as a ESM-only also and ditching cjs/umd builds 😉 |
|
just took a closer look at your package.json and notice this: Lines 62 to 64 in f121491 node-fetch@3 only support 12.20 and above... |
|
Thanks for the notes! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #856 +/- ##
==========================================
- Coverage 65.48% 64.17% -1.31%
==========================================
Files 7 7
Lines 788 790 +2
==========================================
- Hits 516 507 -9
- Misses 272 283 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hello Jimmy, looking to get this merged in but it looks like some of the tests are failing. I think for the time being at least, we want to ship CJS/UMD in addition to ESM due to additional compatibility since we are trying to reach the largest number of consumers as we can. With that in mind, I think I would also request we modify this to not bump the required version and keep the code such that it can run with both the 2 and 3 major version of node-fetch. Let me know if this all makes sense and you are able to make the changes! If not, I can take of the diff and go from there |
|
Best you take the diff and go from there |
|
|
|
Now that fetch is built into NodeJS itself then i think you should be doing const { fetch } = globalThisif it isn't avalible then user can polyfill it themself with whatever fetch compatible package they choose |
|
@jimmywarting Thanks for the information! |
Hi, I'm a core team member of node-fetch, part of our v3 release was to ship it as a ESM-only, so you are no longer able to use require to import it...
Using the latest node-fetch release in your SDK was a tiny bit tricky cuz you still depend on shipping dual esm/cjs support. That meant that it can't use regular import syntax either cuz your
importsyntax is converted intorequire()calls. So without making a too breaking change and only demand that the dropbox sdk should be shipped as esm-only then i needed to circumvent the compiler by using a Eval function and force the use of lazyimport()dynamic import works from NodeJS v12.20 in commonjs
this way node-fetch will be lazy loaded only when needed, so bootup should be faster...
Checklist
General Contributing
Is This a Code Change?
Validation
npm testpass?npm run buildpass?npm run lintpass?