What are the possible downsides of converting a form to package?

When I open an old app, I see an automatic commit called "Automatically migrate old app features".

This makes me think that Anvil has developed new features that can be automatically implemented without risk of introducing a regression.

I also see the warning "Warning: Displaying form "MyForm" as a skeleton in designer because it is a module form. Convert it to a package to interact with it live in the designer."

This makes me think that the conversion to package was not included in the automatic migration because there might be reasons not to do it.

Hence the question: can I blindly right click on every form and module and convert to package, without risk of breaking anything?
If no, why?
If yes, why isn’t this happening together with the automatic migration?

Whenever I do it, it often breaks the resulting package, by requiring me to adjust its (app-specific) import statements. Typically, I need to add a . at the start.

This is trivial to fix, but since it doesn’t happen automatically, I need to allocate some extra time to handle it.

If the resulting package is a Custom Component, and I’ve used it, then I may also need to add code to it, to prevent design-time Exceptions, resulting from the in-component code being called at the wrong time (i.e., when the appropriate resources are not accessible at design time in the IDE).

This is not so trivial to fix, and probably can’t be automated. (Especially since I occasionally have custom components nested 3 or more levels deep.) In any case, I need to allocate some extra time to handle that, too.

Converting a Form to a Package can thus turn into a self-contained subproject, without warning. To me, that extra time is a good reason not to do it blindly or automatically.

1 Like

I have noticed the additional dot issue in the imports, but only while importing modules from the same app, not from custom components. I don’t know if the problem doesn’t reproduce with custom components or I was just lucky and haven’t hit that wall yet.

Do you have experience with custom components?

The warning I’m getting is caused by some very old custom components. I would like to get rid of the warnings, because they make up 95% of the content of the app logs.

I tried converting to package all the forms and modules in the custom component and the warnings go away both in the custom component app and in the dependent app.

I am wondering if I can publish the custom component, or I risk to break all the apps that depend from it.

Thoughts?

Yes. Converting a Custom Component is just like converting any other module: any non-Anvil imports it makes will typically need an extra ., and it may need help from _anvil_designer to avoid design-time exceptions.

On the plus side, if it has any “private” modules or Components, those now can reside inside the same package, instead of cluttering the root level of the App.

This has not impacted the code that uses the Custom Component. But then, I haven’t tried making such a change inside a dependency.

I haven’t tried this, so a small experiment may be in order. Results may vary depending on how deeply the custom components are nested…

1 Like