Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid outputting an empty object for nested module with external bindings #7145

Open
nojaf opened this issue Nov 2, 2024 · 3 comments
Open

Comments

@nojaf
Copy link
Contributor

nojaf commented Nov 2, 2024

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.

@zth
Copy link
Collaborator

zth commented Nov 2, 2024

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?

@cristianoc
Copy link
Collaborator

Never emitting an empty module is a bit like never emitting an empty list.

@nojaf
Copy link
Contributor Author

nojaf commented Nov 5, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants