Skip to content
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

ESM / moduleResolution node16 support #94

Closed
Maxim-Mazurok opened this issue Oct 1, 2022 · 1 comment
Closed

ESM / moduleResolution node16 support #94

Maxim-Mazurok opened this issue Oct 1, 2022 · 1 comment

Comments

@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Oct 1, 2022

As suggested in sindresorhus/got#2051 (comment) I changed my moduleResolution to be node16.
And I get this error:

src/utils.ts:4:47 - error TS7016: Could not find a declaration file for module 'hpagent'. '/home/maxim/google-api-typings-generator/node_modules/hpagent/index.mjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/hpagent` if it exists or add a new declaration (.d.ts) file containing `declare module 'hpagent';`

4 import {HttpProxyAgent, HttpsProxyAgent} from 'hpagent';

Project: https://github.com/Maxim-Mazurok/google-api-typings-generator/blob/master/src/utils.ts#L4

Workaround:

  1. Change exports in hpagent/package.json to be "exports": "./index.js",
  2. Use patch-package: npx patch-package hpagent --exclude 'nothing'

Patch:

TODO: Remove this after this is fixed: https://github.com/delvedor/hpagent/issues/94
diff --git a/node_modules/hpagent/package.json b/node_modules/hpagent/package.json
index b9800c2..44c7f8c 100644
--- a/node_modules/hpagent/package.json
+++ b/node_modules/hpagent/package.json
@@ -4,13 +4,7 @@
   "description": "A ready to use http and https agent for working with proxies that keeps connections alive!",
   "main": "index.js",
   "types": "index.d.ts",
-  "exports": {
-    ".": {
-      "require": "./index.js",
-      "import": "./index.mjs"
-    },
-    "./*": "./*.js"
-  },
+  "exports": "./index.js",
   "scripts": {
     "test": "standard && NODE_EXTRA_CA_CERTS=test/fixtures/certs_unit_test.pem ava -v test/*.test.js && tsd",
     "test-ci": "standard && ava -v test/*.test.js && tsd"
@ruckonic
Copy link

fixed with pr #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants