{"id":16919754,"url":"https://github.com/nicolo-ribaudo/legacy-decorators-migration-utility","last_synced_at":"2025-04-11T16:39:24.907Z","repository":{"id":66024893,"uuid":"149519716","full_name":"nicolo-ribaudo/legacy-decorators-migration-utility","owner":"nicolo-ribaudo","description":":top: A command line utility to upgrade your JavaScript files from the legacy decorators proposal to the new one.","archived":false,"fork":false,"pushed_at":"2018-09-21T22:04:44.000Z","size":73,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T12:51:03.139Z","etag":null,"topics":["babel","decorators","ecmascript","javascript","proposal","tc39"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/nicolo-ribaudo.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},"funding":{"github":["nicolo-ribaudo"]}},"created_at":"2018-09-19T22:33:48.000Z","updated_at":"2024-02-16T11:12:23.000Z","dependencies_parsed_at":"2023-02-20T21:46:42.610Z","dependency_job_id":null,"html_url":"https://github.com/nicolo-ribaudo/legacy-decorators-migration-utility","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolo-ribaudo%2Flegacy-decorators-migration-utility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolo-ribaudo%2Flegacy-decorators-migration-utility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolo-ribaudo%2Flegacy-decorators-migration-utility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolo-ribaudo%2Flegacy-decorators-migration-utility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicolo-ribaudo","download_url":"https://codeload.github.com/nicolo-ribaudo/legacy-decorators-migration-utility/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441905,"owners_count":21104099,"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":["babel","decorators","ecmascript","javascript","proposal","tc39"],"created_at":"2024-10-13T19:45:32.498Z","updated_at":"2025-04-11T16:39:24.895Z","avatar_url":"https://github.com/nicolo-ribaudo.png","language":"JavaScript","funding_links":["https://github.com/sponsors/nicolo-ribaudo"],"categories":[],"sub_categories":[],"readme":"# Legacy decorators migration utility\n\nThis repository contains a series of packages that make it easier to migrate\nfrom legacy decorators to the new version of the proposal. This utils are\nmainly meant for decorators consumers, but the `decorators-compat` package could\nalso be used by decorators authors.\nThis utilities only work with class decorators: since object decorators aren't\nincluded in the decorators proposal anymore, you will need to manually remove\nthem.\n\nTL;DR:\n\n```\n$ npx wrap-legacy-decorators path/to/file.js --decorators-before-export\n```\n\n## Packages\n\n### `wrap-legacy-decorators`\n\nThis package contains a command line utility to upgrade a JavaScript file to the\ncurrent decorators semantics. It is meant to be either used with `npx` or\ninstalled globally:\n\n```\n$ npx wrap-legacy-decorators file.js\n\nOR:\n\n$ npm install --global wrap-legacy-decorators\n$ wrap-legacy-decorators file.js\n\nOR:\n\n$ yarn global add wrap-legacy-decorators\n$ wrap-legacy-decorators file.js\n```\n\nIt also works with multiple files:\n\n```\n$ npx wrap-legacy-decorators foo.js bar.js\n\nOR:\n\n$ npx wrap-legacy-decorators src/**/*.js\n```\n\n#### Options\n\n| **Option**           | **Description**           |\n|----------------------|---------------------------|\n| `-h, --help`         | Show usage information.   |\n| `-v, --version`      | Show the utility version. |\n| `--decorators-before-export` or `--decorators-after-export` | (*Required*) Sets the position of decorators relative to the `export` keyword. |\n| `--external-helpers` | Use the `decorators-compat` package instead of inserting the helper inline in each file. |\n| `--write`            | Update the file in-place, instead of printing the modified code to the console. | \n\n### `decorators-compat`\n\nThis module exports a function which wraps any legacy decorator, making it compatible with the new proposal. If you are using the `wrap-legacy-decorators` command with the `--external-helpers` flag, you must add this package to your dependencies:\n\n```\n$ npm install --save decorators-compat\n\nOR:\n\n$ yarn add decorators-compat\n```\n\n#### Usage\n\n```js\n// If you where using a legacy decorator like this:\n\n@legacyDecorator1\n@legacyDecorator2\nclass Foo {}\n\n// ... when upgrading to the new proposal it should become something like this:\n\nimport decoratorsCompat from \"decorators-compat\";\n\n@decoratorsCompat([legacyDecorator1, legacyDecorator2])\nclass Foo {}\n```\n\n#### Caveats\n\nSince legacy decorators are applyed to the finished class rather then to an intermediate representation, they always run *after* modern decorators. For this reason, it is highly reccomended to write the legacy decorators you are using *before* the modern decorators.\n\n### `babel-plugin-wrap-legacy-decorators`\n\nThis Babel plugin is used internally by the `wrap-legacy-decorators` command line utility. It accepts two options: `decoratorsBeforeExport: boolean` and `externalHelpers: boolean`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolo-ribaudo%2Flegacy-decorators-migration-utility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolo-ribaudo%2Flegacy-decorators-migration-utility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolo-ribaudo%2Flegacy-decorators-migration-utility/lists"}