···226226227227 ([sobolevn](https://github.com/sobolevn))
228228229229+- The `erlang.application_start_argument` parameter has been added to
230230+ `gleam.toml`. This is a string containing an Erlang term that will be written
231231+ into the package's Erlang `.app` file if `erlang.application_start_module`
232232+ has been set, replacing the default argument of `[]`.
233233+ ([Louis Pilfold](https://github.com/lpil))
234234+229235- Generated code for the JavaScript target now includes a public API which can
230236 be used for FFI interacting with Gleam custom types. For example, if you have
231237 this Gleam code:
···104104105105 let path = self.output_directory.join(format!("{}.app", &config.name));
106106107107- let start_module = config
108108- .erlang
109109- .application_start_module
110110- .as_ref()
111111- .map(|module| tuple("mod", &format!("{{'{}', []}}", module_erlang_name(module))))
112112- .unwrap_or_default();
107107+ let start_module = match config.erlang.application_start_module.as_ref() {
108108+ None => "".into(),
109109+ Some(module) => {
110110+ let module = module_erlang_name(module);
111111+ let argument = match config.erlang.application_start_argument.as_ref() {
112112+ Some(argument) => argument.as_str(),
113113+ None => "[]",
114114+ };
115115+ tuple("mod", &format!("{{'{module}', {argument}}}"))
116116+ }
117117+ };
113118114119 let modules = modules
115120 .iter()
+8
compiler-core/src/config.rs
···708708709709#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Default, Clone)]
710710pub struct ErlangConfig {
711711+ /// An module that can be set in the `.app` file as the entrypoint for a stateful application
712712+ /// that defines a singleton supervision tree.
713713+ /// Erlang syntax.
711714 #[serde(default)]
712715 pub application_start_module: Option<EcoString>,
716716+ /// The argument for the start module start function. If not set then `[]` is used as the
717717+ /// default argument.
718718+ /// Erlang syntax.
719719+ #[serde(default)]
720720+ pub application_start_argument: Option<EcoString>,
713721 #[serde(default)]
714722 pub extra_applications: Vec<EcoString>,
715723}