Custom Module to Re-use Code

Has anyone built a custom starlark module? Or could point me to some documentation as to how to do it?

I would like to re-use some code between different apps. I made a .star file with the variables and functions I want to re-use. Then tried to load it into another .star file with this command:

load(“”, “testmod”)

But I keep getting the following error – saying Invalid Module:

error loading applet: failed to load applet: starlark.ExecFile: cannot load invalid module:

Are there certain requirements that need to be met for a .star file to be loaded through the load command?

Hi @JeffreyEsser!

It is not currently possible to load arbitrary Starlark code from a file. The load command has hardcoded list of acceptable filenames:

1 Like

Thanks @drudge for the quick answer!

Maybe you could make a generic app template with your code that everyone could use. I think it would be nice to have a feature rich app template.