{"id":13834687,"url":"https://github.com/dropbox/ts-transform-react-constant-elements","last_synced_at":"2025-10-09T22:46:00.717Z","repository":{"id":34997381,"uuid":"162339145","full_name":"dropbox/ts-transform-react-constant-elements","owner":"dropbox","description":"A TypeScript AST Transformer that can speed up reconciliation and reduce garbage collection pressure by hoisting React elements to the highest possible scope.","archived":false,"fork":false,"pushed_at":"2023-08-29T21:27:45.000Z","size":146,"stargazers_count":44,"open_issues_count":11,"forks_count":6,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-07-01T10:50:22.468Z","etag":null,"topics":["ast","constant","elements","optimization","react","transform","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dropbox.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}},"created_at":"2018-12-18T19:59:46.000Z","updated_at":"2023-03-10T12:02:17.000Z","dependencies_parsed_at":"2024-01-15T18:54:38.065Z","dependency_job_id":"a2932cb6-eb28-4aeb-aaab-fd0cc6f1325b","html_url":"https://github.com/dropbox/ts-transform-react-constant-elements","commit_stats":{"total_commits":44,"total_committers":6,"mean_commits":7.333333333333333,"dds":0.5681818181818181,"last_synced_commit":"6a4cf52a5a519cfe796eb8cb08cb9e801bf683f2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dropbox/ts-transform-react-constant-elements","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-react-constant-elements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-react-constant-elements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-react-constant-elements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-react-constant-elements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dropbox","download_url":"https://codeload.github.com/dropbox/ts-transform-react-constant-elements/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fts-transform-react-constant-elements/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264545157,"owners_count":23625403,"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":["ast","constant","elements","optimization","react","transform","typescript"],"created_at":"2024-08-04T14:00:51.067Z","updated_at":"2025-10-09T22:45:55.685Z","avatar_url":"https://github.com/dropbox.png","language":"TypeScript","readme":"# ts-transform-react-constant-elements\n\n![build status](https://travis-ci.org/dropbox/ts-transform-react-constant-elements.svg?branch=master)\n\nThis is a TypeScript AST Transformer that can speed up reconciliation and reduce garbage collection pressure by hoisting React elements to the highest possible scope, preventing multiple unnecessary reinstantiations, similar to [babel-plugin-transform-react-constant-elements](https://babeljs.io/docs/en/babel-plugin-transform-react-constant-elements).\n\nExample:\n```ts\nconst Hr = () =\u003e {\n  return \u003chr className=\"hr\" /\u003e;\n};\n\n// becomes \nconst _ref = \u003chr className=\"hr\" /\u003e;\n\nconst Hr = () =\u003e {\n  return _ref;\n};\n```\n\nThis is especially useful for hoisting static but expensive content such as SVG.\n\n## Usage\nFirst of all, you need some level of familiarity with the [TypeScript Compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API).\n\n`compile.ts` \u0026 tests should have examples of how this works. The available options are:\n\n### `verbose?: boolean`\nEnabling this will allow this transformer to log out which nodes are hoisted.\n\n## License\n\nCopyright (c) 2018 Dropbox, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["Transformers"],"sub_categories":["React"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fts-transform-react-constant-elements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdropbox%2Fts-transform-react-constant-elements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fts-transform-react-constant-elements/lists"}