Closed PeS82 closed 1 year ago
Why are you importing the base client? Import the socket client.
Because amqp.connect()
(AMQPClient
) returns AMQPBaseClient
.
There is exported AMQPWebSocketClient
which is not what I want (I believe) in the server environment (i.e. not in the browser)?
In your tsconfig.json
set moduleResolution
to either bundler
or node16
. Then import like this:
import { AMQPBaseClient } from "@cloudamqp/amqp-client/amqp-base-client";
If you are only using it as a type, then adding the type specifier will remove it from the built output:
import type { AMQPBaseClient } from "@cloudamqp/amqp-client/amqp-base-client";
Thank you very much for the help, quick response and for the library. It is resolved now.
When using the library in TypeScript project configured to use ESM the imports from
types
are failing.package.json
has"type": "module"
tsconfig
:The
AMQPBaseClient
is then imported asand during runtime (using
ts-node-esm
) or compilation (tsc
) it fails with errorCannot find module '@cloudamqp/amqp-client/types/amqp-base-client.js' or its corresponding type declarations.
The solution I came up with is to add export to
node_modules/@cloudamqp/amqp-client/types/index.d.ts
:and then import in the project simply as
Not sure whether this is the right solution. Could you please modify the library to work with ESM?