镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

rollup/commonjs plugin sometimes fails to detect circular dependency #1425

Closed

Description

@dskloetd
  • Rollup Plugin Name: rollup/plugin-commonjs
  • Rollup Plugin Version: 24.0.0
  • Rollup Version: 3.12.0
  • Operating System (or Browser): MacOS 13.2 (or Chrome 109.0.5414.119 (Official Build) (arm64) )
  • Node Version: 18.13.0
  • Link to reproduction (⚠️ read below): https://github.com/dskloetd/rollup-bug

Expected Behavior

All modules with circular dependencies should be wrapped in a "require wrapper".

Actual Behavior

The CommonJS plugin in rollup has a bug where it sometimes fails to detect a
circular dependency. The issue that this call to isCyclic
happens before the dependency graph is fully built and so
loadModule(resolved) might be skipped while it shouldn't be.
And then getTypeForFullyAnalyzedModule
here
is called before the module is indeed fully analyzed. Then the module doesn't
get a "require wrapper" while it does need one.

Additional Information

Activity

  1. added a commit that references this issue on Mar 7, 2023
  2. lukastaegert commented on Mar 13, 2023

    @lukastaegert
    Member

    There are indeed some problematic edge cases in the logic. Even worse, it can be that depending on race conditions in the module resolution, the output can become non-deterministic with regard to which modules are wrapped.
    For that reason (and because the logic is really complicated) I am considering removing that logic again and instead to make strictRequires: true the default, with the option to manually opt out of this behavior for some or all modules.

  3. dskloetd commented on Mar 13, 2023

    @dskloetd
    Author

    Non-deterministic builds is indeed how I discovered the issue in the first place.

  4. stale commented on May 22, 2023

    @stale

    Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ

  5. dskloetd commented on May 22, 2023

    @dskloetd
    Author

    disappointing

  6. stale commented on Aug 12, 2023

    @stale

    Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions