{"id":18581571,"url":"https://github.com/ember-codemods/ember-modules-codemod","last_synced_at":"2025-08-11T21:05:54.395Z","repository":{"id":44159707,"uuid":"71059291","full_name":"ember-codemods/ember-modules-codemod","owner":"ember-codemods","description":"Codemod to upgrade Ember apps to JavaScript (ES6) modules","archived":false,"fork":false,"pushed_at":"2023-10-19T14:33:47.000Z","size":453,"stargazers_count":96,"open_issues_count":38,"forks_count":38,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-05T23:12:15.500Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ember-codemods.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":"2016-10-16T15:30:06.000Z","updated_at":"2024-01-19T10:01:09.000Z","dependencies_parsed_at":"2024-06-18T17:13:34.032Z","dependency_job_id":null,"html_url":"https://github.com/ember-codemods/ember-modules-codemod","commit_stats":{"total_commits":160,"total_committers":25,"mean_commits":6.4,"dds":0.80625,"last_synced_commit":"4043263a887618b77f9ce30fdfa91605ca82c210"},"previous_names":["ember-cli/ember-modules-codemod"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-codemods%2Fember-modules-codemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-codemods%2Fember-modules-codemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-codemods%2Fember-modules-codemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-codemods%2Fember-modules-codemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-codemods","download_url":"https://codeload.github.com/ember-codemods/ember-modules-codemod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230462914,"owners_count":18229865,"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":[],"created_at":"2024-11-07T00:06:10.077Z","updated_at":"2024-12-19T16:12:56.717Z","avatar_url":"https://github.com/ember-codemods.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ember Modules Codemod\n\n[![npm version](https://badge.fury.io/js/ember-modules-codemod.svg)](https://badge.fury.io/js/ember-modules-codemod)\n[![Build Status](https://travis-ci.org/ember-cli/ember-modules-codemod.svg?branch=master)](https://travis-ci.org/ember-cli/ember-modules-codemod)\n[![Build status](https://ci.appveyor.com/api/projects/status/q0tmqlbgdtfnnss7/branch/master?svg=true)](https://ci.appveyor.com/project/embercli/ember-modules-codemod/branch/master)\n\nThis codemod uses [`jscodeshift`](https://github.com/facebook/jscodeshift) to update an Ember application to\nimport framework code using module syntax, as proposed in [RFC 176: JavaScript Module API](https://github.com/emberjs/rfcs/pull/176). It can update apps that use the global `Ember`, and will eventually also support\napps using [ember-cli-shims][shims].\n\n[shims]: https://github.com/ember-cli/ember-cli-shims\n\nFor example, it will rewrite code that looks like this:\n\n```js\nexport default Ember.Component.extend({\n  isAnimal: Ember.computed.or('isDog', 'isCat')\n});\n```\n\nInto this:\n\n```js\nimport Component from '@ember/component';\nimport { or } from '@ember/object/computed'\n\nexport default Component.extend({\n  isAnimal: or('isDog', 'isCat')\n});\n```\n\n## Usage\n\n**WARNING**: `jscodeshift`, and thus this codemod, **edit your files in place**.\nIt does not make a copy. Make sure your code is checked into a source control\nrepository like Git and that you have no outstanding changes to commit before\nrunning this tool.\n\nThe simplest way to use the codemod is like this:\n\n```sh\nnpm install ember-modules-codemod -g\ncd my-ember-app\nember-modules-codemod\n```\n\nOr using `npx`:\n\n```sh\nnpx ember-modules-codemod\n```\n\n### Paths\n\nBy default, `ember-modules-codemod` will apply changes on files in the following folders:\n\n```\napp/\naddon/\naddon-test-support/\nlib/\ntests/\ntest-support/\n```\n\nYou can also execute the codemod in a specific folder:\n\n```sh\nember-modules-codemod my-folder-to-modify\n```\n\n#### Unknown Globals\n\nIf the codemod finds a use of the `Ember` global it doesn't know how to\ntranslate, it will write a report to `MODULE_REPORT.md`. You can use this report\nas the basis for filing support issues or contributing to the RFC.\n\n#### Standalone\n\nThis package includes an `ember-modules-codemod` binary that wraps `jscodeshift`\nand invokes it with the correct configuration when inside the root directory of\nan Ember app.\n\nIf you're comfortable with `jscodeshift` already or would rather use it\ndirectly, you can clone this repository and invoke the transform manually:\n\n```sh\nnpm install jscodeshift -g\ngit clone https://github.com/ember-cli/ember-modules-codemod\ncd my-ember-app\njscodeshift -t ../ember-modules-codemod/transform.js app\n```\n\nNote that invoking the transform directly disables the generation of the\nMarkdown report if any unknown globals are discovered.\n\n## Contributing\n\n### Running Tests\n\n```sh\nyarn test // run all tests once\nyarn test -- --watchAll // continuously run tests\nyarn test:debug // run tests in debug mode (using Chrome's chrome://inspect tab)\n```\n\nTests for this codemod work by comparing a paired input and output file in the `__testfixtures__` directory.  Pre-transform files should be of format `\u003ctest-name\u003e.input.js`, expected output after the transform should be named `\u003ctest-name\u003e.output.js`. Files must use the same `\u003ctest-name\u003e` in their names so they can be compared.\n\n### Transform Bugs\n\nIf you discover a file in your app that the codemod doesn't handle well, please\nconsider submitting either a fix or a failing test case.\n\nFirst, add the file to the `test/input/` directory. Then, make another file with\nthe identical name and put it in `test/expected-output/`. This file should\ncontain the JavaScript output you would expected after running the codemod.\n\nFor example, if the codemod fails on a file in my app called\n`app/components/my-component.js`, I would copy that file into this repository as\n`test/input/my-component.js`. Ideally, I will edit the file to the smallest\npossible test case to reproduce the problem (and, obviously, remove any\nproprietary code!). I might also wish to give it a more descriptive name, like\n`preserve-leading-comment.js`.\n\nNext, I would copy *that* file into `test/input/my-component.js`, and hand apply\nthe transformations I'm expecting.\n\nThen, run `npm test` to run the tests using Mocha. The tests will automatically\ncompare identically named files in each directory and provide a diff of the\noutput if they don't match.\n\nLastly, make changes to `transform.js` until the tests report they are passing.\n\nIf you are submitting changes to the transform, please include a test case so we\ncan ensure that future changes do not cause a regression.\n\n### Module Changes\n\nIf you want to change how globals are mapped into modules, you will find\nthe data structure that controls that in the `ember-rfc176-data` npm package.\nThe structure is:\n\n```js\n{\n  \"globalPath\": [\"moduleName\", \"namedExport\"?, \"localName\"?]\n}\n```\n\nOnly the first item in the array is mandatory. The second item is only needed\nfor named exports. The third item is only necessary if the local identifier the\nimport is bound to should be different than named export (or the previous global\nversion, in the case of default exports).\n\nA few examples:\n\n1. `Ember.Application` ⟹ `'Application': ['ember-application']` ⟹ `import Application from 'ember-application'`\n1. `Ember.computed.or` ⟹ `'computed.or': ['ember-object/computed', 'or']` ⟹ `import { or } from 'ember-object/computed'`\n1. `Ember.DefaultResolver` ⟹ `'DefaultResolver': ['ember-application/globals-resolver', null, 'GlobalsResolver']` ⟹ `import GlobalsResolver from 'ember-application/globals-resolver'`\n\n### Known Issues\n\nThere are some limitations in the current implementation that can hopefully be\naddressed in the future. PRs welcome!\n\n* Apps using `ember-cli-shims` are not updated.\n* All long imports are beautified, even non-Ember ones.\n* Namespace imports (`import * as bar from 'foo'`) are not supported.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-codemods%2Fember-modules-codemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-codemods%2Fember-modules-codemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-codemods%2Fember-modules-codemod/lists"}