{"id":15490650,"url":"https://github.com/sammarks/rush-demo-linked-packages","last_synced_at":"2025-03-28T16:27:58.958Z","repository":{"id":147095160,"uuid":"308064739","full_name":"sammarks/rush-demo-linked-packages","owner":"sammarks","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-28T15:51:58.000Z","size":99,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T09:19:33.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/sammarks.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":"2020-10-28T15:45:23.000Z","updated_at":"2020-10-28T15:52:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b8969df-91ce-401f-946f-253b61ad92f6","html_url":"https://github.com/sammarks/rush-demo-linked-packages","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"5fe93ebb257621b99de066d21e4f217a5ad0478c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Frush-demo-linked-packages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Frush-demo-linked-packages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Frush-demo-linked-packages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Frush-demo-linked-packages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sammarks","download_url":"https://codeload.github.com/sammarks/rush-demo-linked-packages/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246061881,"owners_count":20717520,"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-10-02T07:22:56.825Z","updated_at":"2025-03-28T16:27:58.926Z","avatar_url":"https://github.com/sammarks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rush Linked Packages Demo\n\nThis is a demonstration repository for the proof-of-concept I introduced in\n[this PR.](https://github.com/microsoft/rushstack/pull/2301) See my explanation inside that PR\nfor how this works / how to use it.\n\n## Initial Setup\n\nThis repository contains two completely separate rush projects (they're in the same repo for\nsimplicity). `rush-one` is a bunch of helper packages, and a replacement for `lodash` (which we\nwill be using later). `rush-two` contains `@test/project-three`, which has a `bin.js` file inside\nit. We will be running that whenever checking to see if the packages linked properly.\n\nTo start, `rush update` in both `rush-one` and `rush-two` to get all of the dependencies installed,\nand then `rush build` inside each to get the packages built.\n\nOnce everything is built, you should be able to run `node rush-two/packages/project-three/dist/bin.js`\nand you should be greeted with something like the following:\n\n```\nwelcome to the CLI\nhere is project two, and now we are getting...\nbar\n```\n\n## Linking Packages\n\n**Make sure you're using a version of `rush` built from my code in the PR.** If you're not using the\ncode from the PR, it should still work. You'll just get some warnings and error messages, and it\nwon't work _as well._\n\nNow, to demonstrate the linking functionality, we'll go back and update the `links.json` file inside\nthe `rush-two` project to link to the `lodash` package in `rush-one` instead of the one from NPM.\n\n**Note:** Normally, `links.json` should be excluded from your repository, as the packages you have\nlinked should only be a local configuration (they also include local path references, so even more\nof a reason to ignore them). I'm including them in this repository for the sake of the\ndemonstration.\n\n*The only reason I'm using lodash instead of some other package is because I had to pick something\navailable on NPM so the first installation (where they're not linked) works properly.\nConveniently, when the package is defined in `links.json`, it doesn't have to be published, which is\nnice when developing packages in another repo that haven't yet been published.*\n\nCopy `links.example.json` to `links.json` inside `rush-two/common/config`, and then run\n`rush update` to install the linked version of the package instead. You'll see some console messages\nverifying that it is indeed using the linked version.\n\n**Do not attempt to build the packages with the linked packages.** You can try, but you'll either\nsee error messages because one of the packages used to build the code uses `lodash`, or you'll\nsee error messages complaining about the types.\n\nNow, run `node rush-two/packages/project-three/dist/bin.js` and you should get something like this:\n\n```\nwelcome to the CLI\nhere is project two, and now we are getting...\nboom\n.../rush-demo-linked-packages/rush-one/packages/lodash/dist/index.js:10\n    throw new Error('stonks');\n\n...\n```\n\n`boom` is there to illustrate calling another package from within the Rush repository you're\nreferencing, and then the error is our replacement for the `lodash` code.\n\n## Going Back\n\nFinally, to go back to the non-linked version (and this is the currently-cumbersome part), you'll\nneed to first reset your `links.json` file, then remove the `node_modules` directories in all of\nthe packages (I find this gets PNPM to reset the linked packages, otherwise it just uses the linked\npackage again), and then run `rush update --full` to re-install all the dependencies. From the\n`rush-two` folder:\n\n```\necho \"{}\" \u003e common/config/links.json\nrm -rf */*/node_modules\nrush update --full\n```\n\nFinally, run `node rush-two/packages/project-three/dist/bin.js` and you should get the original\nmessage again:\n\n```\nwelcome to the CLI\nhere is project two, and now we are getting...\nbar\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammarks%2Frush-demo-linked-packages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammarks%2Frush-demo-linked-packages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammarks%2Frush-demo-linked-packages/lists"}