-
Notifications
You must be signed in to change notification settings - Fork 43
Don't require esModuleInterop
downstream
#55
Conversation
This change updates Node stdlib imports to use the following ES6 import style: ``` import * as x from 'x'; ``` This allows downstream TypeScript projects (direct or transitive) to use node-agent-base without enabling the esModuleInterop option. Ideally, it would be nice not to force users to enable this option if they don't want it.
@@ -13,7 +13,7 @@ import { Agent, RequestOptions } from '../src'; | |||
// versions we have to patch the internal `_http_agent` module instead | |||
// (see: https://github.com/nodejs/node/pull/25170). | |||
// @ts-ignore | |||
import httpAgent from '_http_agent'; | |||
import * as httpAgent from '_http_agent'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the // @ts-ignore
means we don't have to do the require()
hack that was necessary for https
below.
Looks good, but the package hasn't been updated in months. Seems unlikely you'll get a merge. |
I'm potentially open to this change. However, I wonder how are you consuming this module? Are you using the source TypeScript files directly or the compiled version from the |
Sure. We ran into issue when adding Our current workaround is to use |
I ran also today into this issue :/ Would be great if you would fix it. |
The issue is happening when you have a "normal" typescript project without esModuleInterop set to true. When you import ProxyAgent, it will also use your package. So when the typings are imported, your esModule import will break your project, as it can not determine what this means. This is your current tarball in npm: So it uses the typings in the dist folder, which have esModuleInterop imports. |
Without enabling
|
esModuleInterop
downstream
@TooTallNate Do you plan to merge this? |
@TooTallNate Any updates on this? |
This code in this repository has been moved to the |
This change updates Node stdlib imports to use the following ES6 import style:
This allows downstream TypeScript projects (direct or transitive) to use node-agent-base without enabling the esModuleInterop option. Ideally, it would be nice not to force users to enable this option if they don't want it.
To prevent regression, this PR switches off the
esModuleInterop
option in this package's owntsconfig.json
. This means that the test suite also needed to be updated. In particular, the case that modifieshttps.globalAgent
requires a slight tweak, because ES6 module imports mark modules as read-only for the importing scope.