migrate commonjs to esm #574
Merged
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.
This is mostly a find/replace of
require
toimport
, with little practical changes.This is a breaking change for anyone who uses configproxy from another js package via undocumented
require('configurable-http-proxy')
API, but I think that is probably zero people, and now technically only breaks on users of node 18, as you canrequire
esm modules starting with node 20, which is the oldest supported LTS version by node.js itself, as of this month.Trades coverage tool nyc for equivalent c8, since nyc doesn't support esm.
closes #563 by upgrading node-fetch, which is what prompted this change since it's an esm.
We could improve the code a lot by moving to async/await from chaining promises. That's purely internal, though, whereas this is an API change (though an undocumented, unsupported API that I think nobody uses), so I wanted to do it as part of the already major bump due to the nodejs increase with http-proxy-3.