import gleam/io
// A type with no Gleam constructors
pub type DateTime
// An external function that creates an instance of the type
@external(javascript, "./my_package_ffi.mjs", "now")
fn now() -> DateTime
// The `now` function in `./my_package_ffi.mjs` looks like this:
// export function now() {
// return new Date();
// }
pub fn main() {
io.debug(now())
}
gleam run
Then it runs as expected. If I then delete ./my_package_ffi.mjs from the src directory and then do another run, it continues to run. Despite the original src no longer being present. Only after a gleam clean does the run fail with a module not found error like expected. This is the case with both erlang and javascript. I believe this is because the compiler is simply doing a raw copy of the src files that have changed but is not checking if there are build files that should not be present so the old copy is still present.
See https://github.com/gleam-lang/gleam/issues/1970 for more context. If I create a method with FFI like the externals example from the tour and run the code in a new project
gleam run
Then it runs as expected. If I then delete
./my_package_ffi.mjs
from thesrc
directory and then do another run, it continues to run. Despite the original src no longer being present. Only after agleam clean
does the run fail with a module not found error like expected. This is the case with both erlang and javascript. I believe this is because the compiler is simply doing a raw copy of the src files that have changed but is not checking if there are build files that should not be present so the old copy is still present.