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

When compiled with Rollup, shows warnings: Circular dependency #42

Open
francoisromain opened this issue Feb 21, 2018 · 14 comments
Open

Comments

@francoisromain
Copy link

Hello
When this module is listed as a dependency and compiled with Rollup, this shows the following warnings:

(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/fingerprint.js
(!) Circular dependency: node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/fingerprint.js
(!) Circular dependency: node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/signature.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/dhe.js ->node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/dhe.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/dhe.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/dhe.js ->commonjs-proxy:/node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/dhe.js -> commonjs-proxy:/node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/dhe.js -> commonjs-proxy:/node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/ed-compat.js -> node_modules/sshpk/lib/signature.js
(!) Circular dependency: node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/ed-compat.js -> commonjs-proxy:/node_modules/sshpk/lib/signature.js-> node_modules/sshpk/lib/signature.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/formats/pem.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/formats/pkcs8.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/formats/pkcs8.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/formats/pkcs8.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/formats/pkcs8.js -> node_modules/sshpk/lib/formats/pem.js
(!) Circular dependency: node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pkcs1.js -> node_modules/sshpk/lib/formats/pkcs8.js -> commonjs-proxy:/node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/pem.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/formats/pem.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/formats/rfc4253.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/formats/rfc4253.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/pem.js -> node_modules/sshpk/lib/formats/ssh-private.js -> node_modules/sshpk/lib/formats/rfc4253.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/ssh.js -> node_modules/sshpk/lib/utils.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/ssh.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/private-key.js -> node_modules/sshpk/lib/formats/auto.js -> node_modules/sshpk/lib/formats/ssh.js -> node_modules/sshpk/lib/private-key.js
(!) Circular dependency: node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/signature.js -> node_modules/sshpk/lib/utils.js -> node_modules/sshpk/lib/private-key.js -> commonjs-proxy:/node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/fingerprint.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/identity.js -> node_modules/sshpk/lib/fingerprint.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/formats/openssh-cert.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/formats/openssh-cert.js -> node_modules/sshpk/lib/certificate.js
(!) Circular dependency: node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/formats/openssh-cert.js -> commonjs-proxy:/node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/certificate.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/formats/x509.js -> node_modules/sshpk/lib/key.js
(!) Circular dependency: node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/formats/x509.js -> node_modules/sshpk/lib/certificate.js
(!) Circular dependency: node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/certificate.js -> node_modules/sshpk/lib/formats/x509-pem.js -> node_modules/sshpk/lib/key.js

I don't know if it is a problem or not.

@danielgindi
Copy link

danielgindi commented Jul 16, 2018

It is a problem, and will make code unexecutable after "rolling up".
The rollup process will convert commonjs deps into "static imports", which do not support circular dependencies.
Then it will end up with a flat hierarchy where there's a reference to a (yet) unset variable.

@danielgindi
Copy link

This is the same thing as here: nodejs/readable-stream#348

@ashgaliyev
Copy link

Is anyone found a solution or workaround as for rollup/rollup#1507 (comment)

@danielgindi
Copy link

You could either restructure the module to remove the circular dependencies, or you could use the new rollup feature when the next release is out.

@jawadrns
Copy link

jawadrns commented Feb 8, 2021

Any update on this?

@danielgindi
Copy link

It's up to you when configuring rollup, to set up dynamicRequireTargets which will simulate commonjs for this module.

In the next commonjs release there will be out of the box handling of circular dependencies for most situations.

@jawadrns
Copy link

jawadrns commented Feb 8, 2021

Do you have any links?

@danielgindi
Copy link

Do you have any links?

Google rollup commonjs...

@gabrielenosso
Copy link

gabrielenosso commented Jul 28, 2021

any update on this?
adding the following config for rollup doesn't seem to solve the issue:

dynamicRequireTargets: [
      '**/node_modules/sshpk/**/*.js',
    ],

It just brings to the message:
Could not dynamically require \"sshpk\"

@danielgindi
Copy link

any update on this?

adding the following config for rollup doesn't seem to solve the issue:


dynamicRequireTargets: [

      '**/node_modules/sshpk/**/*.js',

    ],

It just brings to the message:

Could not dynamically require \"sshpk\"

You may have mixed module types. In this case set transformMixedEsModules: true.

@SylvainGarrigues
Copy link

What's the status on this? Rollup still can't package any project which depends on sshpk:

(!) Circular dependencies
node_modules/sshpk/lib/key.js -> node_modules/sshpk/lib/fingerprint.js -> node_modules/sshpk/lib/key.js

Neither transformMixedEsModules nor dynamicRequireTargets: ["node_modules/sshpk/**/*.js"] solve the issue

@perrin4869
Copy link

You also need to include your entry point into rollup/plugin-commonjs.
Alternatively try v22.0.0-13 which handles circular dependencies automatically!
rollup/plugins#1038

@SylvainGarrigues
Copy link

npm install @rollup/plugin-commonjs@beta --save-dev   

indeed solved the issue without needing any dynamicRequireTargets, thanks @perrin4869!

You mentioned it could alternatively be solved by including an entry point, can you develop that point? I wish I could solve this without relying on beta versions of rollup :)

@perrin4869
Copy link

Well, this won't be in beta much longer haha
But if you need this right now, what you need to do is to have both transformedMixedEsModules, and dynamicRequireTargets as you have set there, and additionally have something like:

import commonjs from "@rollup/plugin-commonjs";

export default {
  plugins: [
    commonjs({ include: [/node_modules/, "./src/my-entry-point.js"] }),
  ],
};

This is because commonjs needs to apply some transformations to the entry point file as well

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

7 participants