{"id":15723230,"url":"https://github.com/ts-defold/tstl-export-as-global","last_synced_at":"2025-05-13T04:30:25.291Z","repository":{"id":57167933,"uuid":"304874049","full_name":"ts-defold/tstl-export-as-global","owner":"ts-defold","description":"TypeScriptToLua plugin that transforms exports into globals","archived":false,"fork":false,"pushed_at":"2024-01-07T01:26:11.000Z","size":600,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-01T15:44:49.820Z","etag":null,"topics":["lua","typescript"],"latest_commit_sha":null,"homepage":"https://ts-defold.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ts-defold.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-10-17T12:35:57.000Z","updated_at":"2024-03-22T05:07:22.000Z","dependencies_parsed_at":"2024-10-24T17:46:30.145Z","dependency_job_id":"dddf3500-9265-47d9-9193-43e269196636","html_url":"https://github.com/ts-defold/tstl-export-as-global","commit_stats":null,"previous_names":["ts-defold/tstl-export-as-global-plugin"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-export-as-global","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-export-as-global/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-export-as-global/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-export-as-global/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ts-defold","download_url":"https://codeload.github.com/ts-defold/tstl-export-as-global/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253876210,"owners_count":21977588,"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":["lua","typescript"],"created_at":"2024-10-03T22:10:44.942Z","updated_at":"2025-05-13T04:30:25.211Z","avatar_url":"https://github.com/ts-defold.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tstl-export-as-global-plugin\n\u003ca href=\"https://discord.gg/eukcq5m\"\u003e\u003cimg alt=\"Chat with us!\" src=\"https://img.shields.io/discord/766898804896038942.svg?colorB=7581dc\u0026logo=discord\u0026logoColor=white\"\u003e\u003c/a\u003e\n\u003e TypeScriptToLua plugin that transforms exports into globals\n\n## Config\n```json\n\"tstl\": {\n  \"luaPlugins\": [\n    { \n      \"name\": \"@ts-defold/tstl-export-as-global\",\n      \"match\": \".*script.ts$\",\n      \"globals\": { \n        \"functions\": [ \"init\", \"on_input\", \"on_message\", \"on_reload\", \"update\", \"final\"]\n      }\n    }\n  ]\n}\n```\nThe config accpets some additional arguments that are required to make this plugin work.\n- `match`: regex pattern of file names to match to apply export transformations to\n- `globals`: object that defines what to match to apply export transformations to\n  - `functions`: array of names to match for export functions to expose as global\n  - `...`: PR welcome for matching constans, variables, etc if you need support.\n\n## Features\nTransform this TypeScript (with config values from above):\n```ts\nfunction no_export() {\n    \"not-exported\";\n}\n\nexport function init() {\n    no_export();\n    \"init\";\n}\n\nexport function update(dt: number) {\n    const val = dt * 100;\n    val * val;\n}\n\nexport function exported() {\n    \"exported\";\n}\n```\n\nTo this lua:\n```lua\n--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]\nlocal ____exports = {}\nlocal function no_export(self)\n    local ____ = \"not-exported\"\nend\nfunction ____exports.init(self)\n    no_export(nil)\n    local ____ = \"init\"\nend\nfunction ____exports.update(self, dt)\n    local val = dt * 100\n    local ____ = val * val\nend\nfunction ____exports.exported(self)\n    local ____ = \"exported\"\nend\ninit = ____exports.init\nupdate = ____exports.update\n```\n\nAny function marked for export is now exposed to the global (file) scope. This plugin was created to expose functions to file scope for the Defold runtime where the runtime expects to call these functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-defold%2Ftstl-export-as-global","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fts-defold%2Ftstl-export-as-global","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-defold%2Ftstl-export-as-global/lists"}