Skip to content

Allow for .custom.hx in module resolution. #10767

@back2dos

Description

@back2dos

It would be nice to have the ability to have a "custom module type" that takes precedence in module resolution.

One concern is the number of lookups. It would be at most 3: .custom.hx, .target.hx and then .hx.

The main use case is building the same app against the same target (or target-agnostic framework such as heaps/openfl/haxeui), but for different devices. The primary concern is UI, so one could for example have SettingsUi.mobile.hx and SettingsUi.desktop.hx.

There are currently two solutions to the above problem:

  1. Have a SettingsUiMobile.hx and SettingsUiDesktop.hx and a SettingsUi.hx aliasing one or the other via conditional compilation, which is a bit noisy.
  2. Build mobile with -cp ./shared -cp ./mobile and desktop with -cp ./shared -cp ./desktop, but that can lead to pretty unpleasant duplication of nested hierarchies.

This is distinct from custom targets in that it's not really compiler target related, but rather gives the user a different layer in the module resolution. It would be used by something like --macro setCustomTargetPlatform("mobile") or more explicitly --macro setCustomModulePostfix("mobile").

It's a bit gimmicky, but it would scratch quite an itch. If anyone sees potential issues or improvements, please come forward ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions