Skip to content

[BUG] Circular Dependency between comparator.js and range.js #318

Closed

Description

@silverwind

There is a circular dependency in semver which rollup will warn about when bundling the module:

classes\comparator.js -> classes\range.js -> classes\comparator.js

Even thought this may work because of Node's resolution mechanism, I'd recommended to refactor.

Activity

  1. isaacs commented on Apr 19, 2020

    @isaacs
    Contributor

    We could maybe do this by putting the intersects method in a different file.

  2. isaacs commented on Apr 19, 2020

    @isaacs
    Contributor

    Oh, actually, that's not possible, because anyone doing require('semver/classes/comparator') will get a broken class.

    I think this is a legitimate case of two classes that have to reference one another, and the refactor will be rather strained. Is there a way to just tell rollup to be ok with it?

  3. gp3gp3gp3 commented on May 2, 2021

    @gp3gp3gp3

    This throws warnings in react native projects with the metro bundler which can't be silenced unless you silence all warnings unfortunately

  4. maietta commented on Feb 12, 2023

    @maietta

    Yeah, I'm still having this problem in 2023...

  5. ilbrando commented on Jun 5, 2024

    @ilbrando

    I'm also having this issue when using rollup to build my package which uses some other packages with a dependency to semver. The semver version used is 7.6.2 (currently the latest). Is there a workaround for this bug?

  6. WarningImHack3r commented on Nov 21, 2025

    @WarningImHack3r

    Still a thing today, with the latest 7.7.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions