How to get around cyclic import issues?

I have two files, parent and child. child imports a variable from parent, and parent imports a variable from child. Changing the variable in parent will change the variable in child, but changing the variable in child will not change the variable in parent.

Is there a way I can resolve these imports without introducing any additional files?

Hey @gabe! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category

For future posts, please make sure your title is a question you’d ask to a friend about Typst. :wink:

You must either keep both variables in parent, or create a file with shared imports as below.

// shared.typ
// Updating it here will update for both parent and child
#let shared-variable = 5

// parent.typ
#import "shared.typ": shared-variable
#let parent-variable = 10

// child.typ
#import "shared.typ": shared-variable
#import "parent.typ": parent-variable
1 Like

There’s no way at all to get around this at the moment? Even with something incredibly convoluted?

The desired effect that I have is to be able to compile both parent and child, having parent act as an aggregator for multiple children and each child being a standalone thing.

I already considered a structure like parent, child, and parentview, where only parentview actually imports the children. This is an unfortunate compromise though since it adds another file and ergonomics are a huge focus for what I’m making.