aackerman / circular-dependency-plugin

Detect circular dependencies in modules compiled with Webpack
https://www.npmjs.com/package/circular-dependency-plugin
ISC License
921 stars 47 forks source link

Incompatibility with ts-loader #46

Closed stavalfi closed 4 years ago

stavalfi commented 5 years ago

It looks like something breaks this awesome plugin.


index.ts:

import Editor from '@editor/editor'

export default Editor

editor.tsx

// @ts-ignore
import DrawFlow from './draw-flow'

export default class Editor {}

console.log(DrawFlow)

draw-flow.js

export default () => {}


errors: (only with ts-loader)

Circular dependency detected: packages/editor/src/draw-flow.js -> packages/editor/src/editor.tsx -> packages/editor/src/draw-flow.js

error

Circular dependency detected: packages/editor/src/editor.tsx -> packages/editor/src/draw-flow.js -> packages/editor/src/editor.tsx


I minimized one of the packages which those errors appeared:

https://github.com/stavalfi/jstream

branch: reproduce-bug

run: yarn install --ignore-scripts && yarn editor

all the webpack stuff is here: cd packages/build/.config/webpack

all this is installed here: packages/build/package.json

"circular-dependency-plugin": "^5.1.0",
"webpack": "^4.35.0",
"ts-loader": "^6.0.0",
"typescript": "^3.5.2",

Please tell me if i can be any assistent to you.

aackerman commented 5 years ago

Would you mind including your plugin configuration?

stavalfi commented 5 years ago
new CircularDependencyPlugin({
      exclude: /node_modules/,
      failOnError: true,
      allowAsyncCycles: false,
      cwd: mainFolderPath, // it's the root of the git repository
    })
stavalfi commented 5 years ago

@aackerman did you find out any clues?

aackerman commented 5 years ago

I spent a couple hours, but I wasn't able to figure it out. I wasn't able to generate a test case that appeared to have the same errors and the setup for jsstream wasn't clear enough for me to break down why it was causing a problem.

aackerman commented 5 years ago

@stavalfi would you be able to break this down into a smaller test case?

stavalfi commented 5 years ago

yes. your work here is a must have in almost any kind of a build system.

In my build system, i extracted all build-related stuff to a different package in the same mono-repo so it is easier to setup a new package with a complete build in couple of minutes (Create React App for mono repos)

aackerman commented 4 years ago

I believe this is fixed in 5.2.2. Please let me know if it's not and I will reopen.