{"id":15408107,"url":"https://github.com/benmerckx/genes","last_synced_at":"2026-03-16T20:31:24.883Z","repository":{"id":43869874,"uuid":"202384222","full_name":"benmerckx/genes","owner":"benmerckx","description":"Generates split ES modules and Typescript definitions from Haxe modules.","archived":false,"fork":false,"pushed_at":"2025-04-21T21:01:42.000Z","size":390,"stargazers_count":45,"open_issues_count":11,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-21T22:21:53.542Z","etag":null,"topics":["es6","haxe","typescript"],"latest_commit_sha":null,"homepage":"","language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benmerckx.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-14T16:07:29.000Z","updated_at":"2025-04-21T21:01:46.000Z","dependencies_parsed_at":"2024-10-21T13:06:38.245Z","dependency_job_id":null,"html_url":"https://github.com/benmerckx/genes","commit_stats":{"total_commits":263,"total_committers":8,"mean_commits":32.875,"dds":"0.15209125475285168","last_synced_commit":"23a95643ca885d3a34708fc9f5b19efd88ab755d"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmerckx%2Fgenes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmerckx%2Fgenes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmerckx%2Fgenes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmerckx%2Fgenes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benmerckx","download_url":"https://codeload.github.com/benmerckx/genes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253178082,"owners_count":21866444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es6","haxe","typescript"],"created_at":"2024-10-01T16:31:31.992Z","updated_at":"2026-03-16T20:31:19.846Z","avatar_url":"https://github.com/benmerckx.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"# genes\n\n[![CI](https://github.com/benmerckx/genes/workflows/CI/badge.svg)](https://github.com/benmerckx/genes/actions)\n\nGenerates split ES6 modules and Typescript definitions from Haxe modules.\n\nRequires Haxe 4+\n\n## Usage\n\n\u003cpre\u003e\u003ca href=\"https://github.com/lix-pm/lix.client\"\u003elix\u003c/a\u003e +lib genes\u003c/pre\u003e\n\nInstall the library and add `-lib genes` to your hxml.\n\n### Defines\n\n| Define                                                                                                                                   | Description                                                                                                                                                                                                                    |\n| ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `-D dts`                                                                                                                                 | generate Typescript definition files                                                                                                                                                                                           |\n| [`-debug`](https://haxe.org/manual/debugging-source-map.html) or [`-D js-source-map`](https://haxe.org/manual/debugging-source-map.html) | generate source maps                                                                                                                                                                                                           |\n| [`-D source_map_content`](https://haxe.org/manual/debugging-source-map-javascript.html)                                                  | include source map contents                                                                                                                                                                                                    |\n| `-D genes.unchanged_no_rewrite`                                                                                                          | don't write output files if there's no change (compares output to file on disk)                                                                                                                                                |\n| `-D genes.extern_init_warning`                                                                                                           | display a warning wherever an extern `__init__` is used as these are not generated by genes                                                                                                                                    |\n| `-D genes.disable`                                                                                                                       | disable genes completely (eg. to compare results to default haxe js generator)                                                                                                                                                 |\n| `-D genes.no_extension`                                                                                                                  | do not use the `.js` extension in import paths                                                                                                                                                                                 |\n| `-D genes.disable_native_accessors`                                                                                                      | do not generate native getter/setters for properties                                                                                                                                                                           |\n| `-D genes.banner`                                                                                                                        | string to be inserted at the beginning of every generated .js file                                                                                                                                                             |\n| `-D genes.dts_banner`                                                                                                                    | string to be inserted at the beginning of every generated .d.ts file                                                                                                                                                           |\n| `-D genes.enum_discriminator`                                                                                                            | emit extra field in enum instance with value equal to the enum constructor name, useful for native js code to consume the enum instead of relying on the default \\_hx_index field. Example `-D genes.enum_discriminator=_kind` |\n\n### Metadata\n\n| Metadata                         | Description                                                                                                 |\n| -------------------------------- | ----------------------------------------------------------------------------------------------------------- |\n| `@:genes.disableNativeAccessors` | on class level or field level to disable generation of native getter/setters for properties                 |\n| `@:genes.type('MyType')`         | overwrite Typescript type in declarations (use on: class, class properties, typedef, type parameters, ....) |\n| `@:genes.returnType('MyType')`   | overwrite Typescript return type in declarations (use on functions)                                         |\n\n## Dynamic imports\n\n```haxe\nimport genes.Genes.dynamicImport;\nimport my.module.A;\nimport my.module.B;\nimport my.module.C;\n// ...\ndynamicImport(A -\u003e new A()).then(trace);\n\ndynamicImport((B, C) -\u003e [new B(), new C()]).then(trace);\n```\n\nRoughly translates to:\n\n```js\nimport(\"./my/module/A\")\n  .then(({ A }) =\u003e new A())\n  .then(console.log);\n\nPromise.all([import(\"./my/module/B\"), import(\"./my/module/C\")])\n  .then((modules) =\u003e [new modules[0].B(), new modules[1].C()])\n  .then(console.log);\n```\n\nGenes expects a function declaration expression (`EFunction`) as the sole argument of `dynamicImport` and it will do 2 things:\n\n1. For each argument, take the argument name (e.g. \"MyClass\") and resolve it as a type in the current context, taking Haxe `import` statements into account. This is for preparing the relative path of the target files (e.g. `'../../MyClass.js'`).\n2. Type the function body in the current context, ignoring the fact that it is a function body. Thus in the example the scope of `A` is not the function argument but in current context i.e. the actual type `class A {...}`. The return type is then applied as the type parameter of `js.lib.Promise`. This is for hinting the return type of the `dynamicImport(...)` call so that the compiler can do its typing job properly.\n\n## Upstream issues\n\n- Performance could be much improved if we could use the compiler to output code.\n  Haxe exposes methods to do so, but without a way to generate source maps for them.\n\n  [HaxeFoundation/haxe#8625](https://github.com/HaxeFoundation/haxe/issues/8625)\n\n- Typescript definitions are pretty much complete. In some cases though there will\n  be references to non-existing types. Haxe does not pass any types that are\n  removed through DCE to the generation phase. However it does pass every typedef\n  used in the project. This means sometimes a type (which it itself is not used)\n  will reference a type that does not exist (removed by DCE).\n  Luckily Typescript won't warn about these issues when your definitions are\n  included as a library but ideally we'd be able to output completely valid types.\n\n  [HaxeFoundation/haxe#9252](https://github.com/HaxeFoundation/haxe/issues/9252)\n\n## Alternatives\n\n- `archived` Split output with require calls: [hxgenjs](https://github.com/kevinresol/hxgenjs)\n- Typescript definition generation: [hxtsdgen](https://github.com/nadako/hxtsdgen)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmerckx%2Fgenes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenmerckx%2Fgenes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmerckx%2Fgenes/lists"}