feat: migrate from CJS to ESM#654
Conversation
There was a problem hiding this comment.
Pull request overview
Migrates the proxy-chain library and its test/docs ecosystem from CommonJS to native ECMAScript Modules (ESM), aligning the project with Node’s modern module system and enabling better tooling/tree-shaking for consumers.
Changes:
- Switches TypeScript compilation and internal source imports to ESM-friendly
NodeNext+ explicit.jsspecifiers. - Converts tests and test utilities from
require()/module.exportstoimport/export, and updates tests to import builtdist/outputs. - Updates package publishing metadata (
type: module,exports) and refreshes README/examples for ESM usage; adjusts release tooling fortype: module.
Reviewed changes
Copilot reviewed 30 out of 32 changed files in this pull request and generated 9 comments.
Show a summary per file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
daniil-poletaev
left a comment
There was a problem hiding this comment.
Left few questions and suggestions
| import proxy from 'proxy'; | ||
| import request from 'request'; | ||
|
|
||
| import { Server } from '../dist/index.js'; |
There was a problem hiding this comment.
are you sure we should import from /dist/ folder? This doesn't look right for me, because user needs to build it first
| @@ -1,3 +1,2 @@ | |||
| { | |||
| "require": "ts-node/register" | |||
There was a problem hiding this comment.
can we remove .mocharc.json completely?
There was a problem hiding this comment.
Or I think we need to do
{
"require": "tsx"
}
and then we can import directly from src?
There was a problem hiding this comment.
It would be nice to migrate to Viteset 😉
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 33 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1,3 +1,2 @@ | |||
| { | |||
| "require": "ts-node/register" | |||
There was a problem hiding this comment.
It would be nice to migrate to Viteset 😉
* feat!: update minimal supported version of Node.js to v20 (#638) * chore: remove typeSocket assertion helper (#653) * feat!: migrate from CJS to ESM (#654) * feat: upgrade typescript to v5 (#655) * feat!: replace nodeify by async/await (#656) * chore: format changelog markdown * docs: add new version info into changelog * chore: bump package version to a major one Close #637

This PR migrates from CJS to ESM.
Close #640