Avoid outputting an empty object for nested module with external bindings
Hi there,
Could it be possible to not output any JS code when doing external only bindings inside a nested module.
Example
type any
type listener
type eventTarget = {}
module EventTarget = {
@send
external addEventListener: (eventTarget, string, listener) => unit =
"addEventListener"
}
leads to
var $$EventTarget = {};
export {
$$EventTarget ,
}
The existence of $$EventTarget seems unnecessary.
Could this be possible?
If so, and this is deemed acceptable I'd be happy to try and contribute this if I get some pointers.
I think that makes sense, IIRC I started looking at this at some point... I don't immediately see a problem with not emitting empty modules at all, regardless of whether they're empty because of externals or not. @cristianoc any thoughts?
Never emitting an empty module is a bit like never emitting an empty list.
Never emitting an empty module is a bit like never emitting an empty list.
Not sure if I follow, an empty list could have meaning where an empty module has none after compilation right?
Already requested this six years ago, this was Bob's response at the time: https://github.com/rescript-lang/rescript/issues/3498#issuecomment-483897516 🙂
I think the problem is that as that module is exported, code in another module could in theory use it (as input to a functor or whatever, although that doesn't make much sense ofc).