Thanks for you answer, @tim.holy.
I tried to use watch_file, but unfortuantely it did not work out as expected. I seemed as if MyModule was kind of waiting for changes in datafile.jld2 and would not continue until the file was changed, but all changes take place before MyModule is used and hence it should check if datafile.jld2 has changed instead of waiting for a change.
However I’m quite greateful for your input and your idea anyway since it brought me on the right track. A solution that works as desired can be implemented by a single line of code, using the Base.include_dependency function.
One would simply need to write
module MyModule
using JLD2, FileIO
export somedata
include_dependency( "../jld2s/datafile.jld2")
@load "../jld2s/datafile.jld2" somedata
end
This has the effect that MyModule will check if datafile.jld2 has changed since the last precompaliation and recompile again if that’s the case, exactly as I want it to be.
I will now consider to store my data in a Dict as you suggested, too, because I think it makes sense.
Thanks for your help!