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

Possible cyclic (circular) dependencies causing issues with Webpack #1092

Open
rquast opened this issue Jul 28, 2017 · 5 comments
Open

Possible cyclic (circular) dependencies causing issues with Webpack #1092

rquast opened this issue Jul 28, 2017 · 5 comments

Comments

@rquast
Copy link
Contributor

rquast commented Jul 28, 2017

I've been using webpack to bundle substance. It worked with beta 6 until I tried beta 7.

I managed to get it to work again by changing the following:

import { getSelectionRect, getRelativeMouseBounds, platform } from '../util'
import { DefaultDOMElement } from '../dom'
import Component from '../ui/Component'

class AbstractScrollPane extends Component {

I changed import { Component } form '../ui' to skip the re-export.

I've tried checking for cyclic dependencies with madge, but I think it crashes each time it hits one.

@obuchtala
Copy link
Member

obuchtala commented Jul 28, 2017

Somehow Rollup is able to deal with the code. At the beginning we had to resolve real cycles such as Selection.js having a factory method depending on PropertySelection.js which apparently extended Selection exported by Selection.js.
webpack seems to be choking with the index.js files.
Have you tried to separate webpack and Substance bundling? I.e. using the single file bundle?

@rquast
Copy link
Contributor Author

rquast commented Jul 28, 2017

Yes, I tried to use the single file bundle, but for some reason or other, it's very slow for webpack to process. I might try forking the project and making a webpack build to see if I can recreate the problem, at least to test new builds.

Other than that small thing, everything works perfectly.

@obuchtala
Copy link
Member

Ok, it's slow, because it really needs to analyse the whole library, and can not drop things on the fly.

@obuchtala
Copy link
Member

obuchtala commented Jul 28, 2017

Maybe it is an option for you to load substance.js via an extra <script> and tell webpack to treat it as external located at window.substance?

Edit: this is what we do in Texture, too

@rquast
Copy link
Contributor Author

rquast commented Jul 28, 2017

That's probably a good idea too. I wasn't really keen on splitting any libraries from the bundle, but the editor is a good exception because of the size.

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

2 participants