refactor: update fetch import for node v21+ compatibility #2573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Related Issue
I've been following those issues on node-fetch node-fetch/node-fetch#1793
And on cross-fetch lquixada/cross-fetch#177
Both seems stale, so I hope that we can fix
quicktype-core
in the meantime. I've used the solution recommended into thecross-fetch
issue toward conditional import and using native node fetch if available.Motivation and Context
We're using
quicktype-core
in some of our tools, one of them being a cli tool, every-time a command is ran the deprecation coming fromquicktype-code
cross-fetch
dependency shows up on node >=v21.Previous Behaviour / Output
New Behaviour / Output
No warning output.
How Has This Been Tested?
quicktype-core
package locally with the changequicktype-core
dependency to point to the local builded packagetgz
and installFetchingJSONSchemaStore
in node scripts to trigger the fetch behaviour with node versions16.20.1
,18.20.2
and21.7.3
v16.20.2
,v18.20.2
,v21.7.3
expected behaviour occurs and the warning is gone.Screenshots (if appropriate):