DataDog / datadog-api-client-typescript

Typescript client for the Datadog API

Home Page:http://datadoghq.dev/datadog-api-client-typescript/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Circular dependency with 1.0.0-beta.9

NinjaBanjo opened this issue · comments

Describe the bug
When consuming @datadog/datadog-api-client@1.0.0-beta.9 using rollup commonjs + node-resolve plugins a circular dependency is raised from the @datadog/datadog-api-client package. Replication steps to follow below

./node_modules/.bin/rollup -c rollup.config.js

index.js → dist/index.mjs...
(!) Circular dependencies
node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/http.js -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/isomorphic-fetch.js -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/http.js
node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/http.js -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/isomorphic-fetch.js -> /home/projects/nextjs-w4drlq/node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/http.js?commonjs-proxy -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/http.js
node_modules/@datadog/datadog-api-client/dist/index.js -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/index.js -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/apis/AWSIntegrationApi.js -> node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/models/ObjectSerializer.js -> node_modules/@datadog/datadog-api-client/dist/index.js
...and 12 more
created dist/index.mjs in 34.6s

To Reproduce
Steps to reproduce the behavior:

  1. open stackblitz https://stackblitz.com/edit/nextjs-w4drlq?file=rollup.config.js
  2. open a terminal in stackblitz linked above
  3. run npm install
  4. run ./node_modules/.bin/rollup -c rollup.config.js
  5. observe circular dependency in terminal after waiting for a few seconds to build

Expected behavior
Expect that rollup is able to complete a build with no circular dependency errors

Screenshots
N/A

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

    "@datadog/datadog-api-client": "^1.0.0-beta.9",
    "@rollup/plugin-commonjs": "^21.0.3",
    "@rollup/plugin-node-resolve": "^13.1.3",
    "rollup": "^2.70.1"

Additional context
N/A

Hi,
Yeah that's because of the logger used in the serializer. Is that an issue in practice though, or just something detected by rollup?

Hi therve,
I'm fairly certain this is a blocker for us deploying it to cloudflare. Without this dependency our code works fine and when I add it I get an error about the cloudflare worker crashing. I'm trying to dig into it more today

Isn't your project a react in-browser project? Because that won't work with datadog-api-client for now anyway.

I don't think there's any react in the cloud flare workers code. Just typescript

Aren't those messages warnings not errors?

Yeah it still builds even with the circular dependency warning but I'm unable to deploy to cloudflare workers after that. Just importing the datadog-api-client-tyepscript into the project and the require statement is enough to break it. I don't know 100% if this lib is the problem but without the import it works and with the import it fails to launch. The only data I have to go on is a warning about a bunch of circular dependencies.

Should be fixed in #616 , which will be in the next release. Thanks!