{"id":13806349,"url":"https://github.com/buschtoens/ember-dead-code","last_synced_at":"2025-04-23T15:43:28.676Z","repository":{"id":47454136,"uuid":"171517657","full_name":"buschtoens/ember-dead-code","owner":"buschtoens","description":"Detect dead code with confidence via real user monitoring","archived":false,"fork":false,"pushed_at":"2023-12-15T05:19:27.000Z","size":156,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-09T12:43:25.831Z","etag":null,"topics":["dead-code-elimination","dead-code-removal","ember","ember-addon","ember-cli","ember-cli-addon","emberjs","real-user-monitoring"],"latest_commit_sha":null,"homepage":null,"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/buschtoens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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-02-19T17:23:44.000Z","updated_at":"2022-08-25T14:52:59.000Z","dependencies_parsed_at":"2024-08-04T01:06:04.815Z","dependency_job_id":"ab3315c9-de83-4d31-aa3d-916186bcf87a","html_url":"https://github.com/buschtoens/ember-dead-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-dead-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-dead-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-dead-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-dead-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buschtoens","download_url":"https://codeload.github.com/buschtoens/ember-dead-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250462763,"owners_count":21434658,"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":["dead-code-elimination","dead-code-removal","ember","ember-addon","ember-cli","ember-cli-addon","emberjs","real-user-monitoring"],"created_at":"2024-08-04T01:01:10.583Z","updated_at":"2025-04-23T15:43:28.661Z","avatar_url":"https://github.com/buschtoens.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Debugging / Profiling"],"readme":"# ember-dead-code\n\n[![Build Status](https://travis-ci.org/buschtoens/ember-dead-code.svg)](https://travis-ci.org/buschtoens/ember-dead-code)\n[![npm version](https://badge.fury.io/js/ember-dead-code.svg)](http://badge.fury.io/js/ember-dead-code)\n[![Download Total](https://img.shields.io/npm/dt/ember-dead-code.svg)](http://badge.fury.io/js/ember-dead-code)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)  \n[![Ember Observer Score](https://emberobserver.com/badges/ember-dead-code.svg)](https://emberobserver.com/addons/ember-dead-code)\n[![Ember Versions](https://img.shields.io/badge/Ember.js%20Versions-%5E2.18%20%7C%7C%20%5E3.0-brightgreen.svg)](https://travis-ci.org/buschtoens/ember-dead-code)\n[![ember-cli Versions](https://img.shields.io/badge/ember--cli%20Versions-%5E2.13%20%7C%7C%20%5E3.0-brightgreen.svg)](https://travis-ci.org/buschtoens/ember-dead-code)  \n[![Dependabot enabled](https://img.shields.io/badge/dependabot-enabled-blue.svg?logo=dependabot)](https://dependabot.com/)\n[![dependencies](https://img.shields.io/david/buschtoens/ember-dead-code.svg)](https://david-dm.org/buschtoens/ember-dead-code)\n[![devDependencies](https://img.shields.io/david/dev/buschtoens/ember-dead-code.svg)](https://david-dm.org/buschtoens/ember-dead-code)\n\nDetects dead code with confidence via real user monitoring. Finds dead\ncomponents, routes, helpers, ember-intl translations and whatever your heart\ndesires!\n\n## The Idea\n\nJavaScript is a dynamic language and notoriously hard to statically analyze.\nWhile it is easy to detect that a certain file or piece of code _is used_,\ndetecting that it _is not used_ is really hard. The fact that components and\nhelpers don't get invoked through JavaScript, but Handlebars, and might even\nhave interpolated names, makes this virtually impossible.\n\nFalse positives are dangerous, as they could lead to deletions that turn up\nweeks later in production, because of some weird edge-case scenario that has not\nbeen accounted for in the analysis.\n\nSo instead of doing the hard work ourselves, why don't we let our users do the\nwork in production for us?\n\n**ember-dead-code** hooks into the [central resolver][ember-resolver], logs\nall lookups and periodically reports them to your backend in batches. This\ntechnique is called [Real User Monitoring][real-user-monitoring].\n\n[ember-resolver]: https://github.com/ember-cli/ember-resolver\n[real-user-monitoring]: https://en.wikipedia.org/wiki/Real_user_monitoring\n\nThe longer you collect data, the more confident you can become that your list of\ncode that is in-use is complete. You can then feed this report back into\n**ember-dead-code** and let it remove dead code for you.\n\n## Installation \u0026 Setup\n\n```\nember install ember-dead-code\n```\n\n## Development Status\n\nSo far this is just an idea and not functional yet. This repo exists so that we\ncan already talk about the concept and review some code.\n\n## FAQ\n\n#### Why run it in production? Can I not collect this data in my acceptance tests?\n\nThere's two problems. If your (acceptance) tests do not cover 100 % of your\ncodebase, **ember-dead-code** will incorrectly report code as dead that is\nactually in use in production. And if your tests _do_ cover 100 % of your\ncodebase, **ember-dead-code** can incorrectly report code that is dead in\nproduction as still in-use.\n\nYou get the most reliable results by monitoring actual production usage.\n\n#### Won't this have a negative performance impact?\n\nThe [`ember-resolver`][ember-resolver] is a central piece to every Ember app and\na very hot code path. Hooking into it and doing a lot of synchronous work would\nof course degrade performance noticeably.\n\nThis is why we try very hard to make the actual data collection as efficient and\nlightweight as possible. The only thing we do inside the resolver is pushing the\nrequested lookup specifier, e.g. `service:foo`, into a shared [`Set`][set], if\nnatively supported, or plain array otherwise.\n\n[set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set\n\nWe then run a task approx. every `n` seconds (you can configure that value!)\nthat deduplicates lookup logs and reports them to the backend, when a\nconfigurable threshold batch size is reached.\n\nIf available, we use [`requestIdleCallback`][requestidlecallback] for this to\nminimize the noticeable performance impact even further. Otherwise we use\n[`later`][later].\n\n[requestidlecallback]: https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback\n[later]: https://emberjs.com/api/api/ember/release/functions/@ember%2Frunloop/later\n\n#### How long do I need to collect data?\n\nYMMV. This depends on the size and behavioral patterns of your user base. We\nrecommend collecting data for at least two weeks, before drawing any\nconclusions. The longer you wait, the more confident you can be in deleting\ncode.\n\nWe also recommend to never stop collecting data. Dead code is an inevitability.\nAs your codebase evolves over time, you will always forget to remove chunks of\ncode. It's nice to have some piece of mind, knowing that your dead code will be\nreported eventually.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuschtoens%2Fember-dead-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuschtoens%2Fember-dead-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuschtoens%2Fember-dead-code/lists"}