Skip to content

migrate commonjs to esm #574

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

Merged
merged 1 commit into from
May 15, 2025
Merged

migrate commonjs to esm #574

merged 1 commit into from
May 15, 2025

Conversation

minrk
Copy link
Member

@minrk minrk commented May 15, 2025

This is mostly a find/replace of require to import, 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 can require 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.

this is a breaking change for anyone who has `require('configurable-http-proxy'),
but I think that might be zero people
Copy link
Member

@manics manics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me

var http = require("http");
var fetch = require("node-fetch");
var spawn = require("child_process").spawn;
const sslOptions = { agent: new https.Agent({ rejectUnauthorized: false }) };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces the NODE_TLS_REJECT_UNAUTHORIZED=0 in npm test

@minrk minrk merged commit f7f790b into jupyterhub:main May 15, 2025
8 checks passed
@minrk minrk deleted the esm branch May 15, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants