Skip to content

dskloetd/rollup-bug

Repository files navigation

Rollup CommonJs plug isCyclic bug repro

The issue in the rollup/plugin repo: rollup/plugins#1425

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 "require wrapper" while it does need one.

The dependency graph between the modules in the repo is like this:

5 <-- 4 <-- 11 <-- 10
|     ^             ^
V     |             |
6     1 <-- main    9
|     |             ^
V     V             |
7 --> 2 <=> 3 ----> 8

If the dependency from module3.js to module2.js is removed, then everything works fine. But as it is, loading index.html fails with TypeError: m4.inc is not a function.

But you don't need to load index.html to observe the issue. Inspect output/main.js and notice that several modules are not inside a "require wrapper" while all but main.js and module1.js have a circular dependency on each other.

Note that the order in which the modules are loaded is not deterministic and depends on when the filesystem responds. It might be possible to reproduce the bug with fewer files but that also makes it more likely that the bug accidentally doesn't happen.

About

Repro rollup isCyclic bug for bug report

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published