{"id":17222908,"url":"https://github.com/rush/link-module-alias","last_synced_at":"2025-04-12T14:57:22.803Z","repository":{"id":44793988,"uuid":"133433429","full_name":"Rush/link-module-alias","owner":"Rush","description":"Register aliases of directories and custom module paths in Node  - no require hook","archived":false,"fork":false,"pushed_at":"2023-07-17T21:42:42.000Z","size":66,"stargazers_count":306,"open_issues_count":13,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T14:11:03.538Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rush.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}},"created_at":"2018-05-14T23:37:14.000Z","updated_at":"2025-02-05T02:12:55.000Z","dependencies_parsed_at":"2024-10-29T18:35:20.670Z","dependency_job_id":null,"html_url":"https://github.com/Rush/link-module-alias","commit_stats":{"total_commits":29,"total_committers":6,"mean_commits":4.833333333333333,"dds":0.4482758620689655,"last_synced_commit":"a0544827e1a252184f1dd138bbec18f3dc5e26d2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Flink-module-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Flink-module-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Flink-module-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rush%2Flink-module-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rush","download_url":"https://codeload.github.com/Rush/link-module-alias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586250,"owners_count":21128997,"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-15T04:06:41.110Z","updated_at":"2025-04-12T14:57:22.778Z","avatar_url":"https://github.com/Rush.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### If you use `@` in your linked module names, there is a risk this module will cause data loss\nSee this issue https://github.com/Rush/link-module-alias/issues/3\n\n# link-module-alias\n\nSetup private modules within your repo to get away from error-prone typing of long relative paths like these:\n```js\nrequire('../../../../some/very/deep/module')\n```\n\nJust create an alias and do it cleanly:\n\n```js\nvar module = require('@deep/module')\n// Or ES6\nimport module from '@deep/module'\n```\n\nYou can setup aliases both to individual files and to directories.\n\n**WARNING** Use this module only in final applications. It will not work inside published npm packages.\n\n## Install\n\n```\nnpm i --save-dev link-module-alias\n```\n\n## Usage\n\nAdd your custom configuration to your `package.json` (in your application's root), and setup automatic initialization in your scripts section.\n\nNote: you can use `@` in front of your module but before of the possible data loss https://github.com/Rush/link-module-alias/issues/3\n\n```js\n\"scripts\": {\n  \"postinstall\": \"link-module-alias\"\n},\n// Aliases\n\"_moduleAliases\": {\n  \"~root\"      : \".\", // Application's root\n  \"~deep\"      : \"src/some/very/deep/directory/or/file\",\n  \"@my_module\" : \"lib/some-file.js\", // can be @ - but see above comment and understand the associated risk\n  \"something\"  : \"src/foo\", // Or without ~. Actually, it could be any string\n  \"module-with-typings\": {\n    \"main\": \"src/path/to/module.js\",\n    \"typings\" \"src/path/to/module/typings.d.ts\" // you can specify typings for files (it works with aliases to files only)\n  }\n}\n```\n\nIf you encounter issues with installing modules, you may want to set up the preinstall script as well:\n```js\n\"scripts\": {\n  \"postinstall\": \"link-module-alias\",\n  \"preinstall\": \"command -v link-module-alias \u0026\u0026 link-module-alias clean || true\"\n}\n```\n\n## How does it work?\n\n- For aliases to directories, we create symlinks with `fs.symlink`\n- For aliases to files, we create proxy modules with a package.json containing `\"main\"` that points to the target file\n\n## Background\n\nThis module it's almost a drop in replacement for another package https://www.npmjs.com/package/module-alias - use module `module-alias` if you like runtime require hooks and use `link-module-alias` if you want good compatibility with your IDE and no runtime hacks.\n\nThe key differentiator of `link-module-alias` is creating all the module links statically in form of symlinks and proxy packages inside `node_modules`, there is no hacky require hook and you don't need to load any supporting packages.\n\nThe key motivator to create `link-module-alias` was to fix the issue with module aliases not resolving in VS Code. https://github.com/ilearnio/module-alias/issues/19\n\n## License\n\nMIT. Attribution to the `module-alias` for parts for the README and original idea.\n\n# Contributors\n\n[@kwburnett](https://github.com/kwburnett)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frush%2Flink-module-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frush%2Flink-module-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frush%2Flink-module-alias/lists"}