{"id":17242769,"url":"https://github.com/imcuttle/absolute-module-mapper-plugin","last_synced_at":"2025-04-06T08:18:08.036Z","repository":{"id":35974612,"uuid":"220622093","full_name":"imcuttle/absolute-module-mapper-plugin","owner":"imcuttle","description":"The plugin on enhanced-resolver to map module path","archived":false,"fork":false,"pushed_at":"2023-01-05T00:42:47.000Z","size":964,"stargazers_count":2,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T02:33:59.093Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imcuttle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-09T09:48:46.000Z","updated_at":"2022-11-13T06:34:23.000Z","dependencies_parsed_at":"2023-01-16T10:16:28.746Z","dependency_job_id":null,"html_url":"https://github.com/imcuttle/absolute-module-mapper-plugin","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/imcuttle%2Fabsolute-module-mapper-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fabsolute-module-mapper-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fabsolute-module-mapper-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2Fabsolute-module-mapper-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imcuttle","download_url":"https://codeload.github.com/imcuttle/absolute-module-mapper-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451657,"owners_count":20940944,"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-15T06:14:01.275Z","updated_at":"2025-04-06T08:18:08.017Z","avatar_url":"https://github.com/imcuttle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# absolute-module-mapper-plugin\n\n[![Build status](https://img.shields.io/travis/imcuttle/absolute-module-mapper-plugin/master.svg?style=flat-square)](https://travis-ci.org/imcuttle/absolute-module-mapper-plugin)\n[![Test coverage](https://img.shields.io/codecov/c/github/imcuttle/absolute-module-mapper-plugin.svg?style=flat-square)](https://codecov.io/github/imcuttle/absolute-module-mapper-plugin?branch=master)\n[![NPM version](https://img.shields.io/npm/v/absolute-module-mapper-plugin.svg?style=flat-square)](https://www.npmjs.com/package/absolute-module-mapper-plugin)\n[![NPM Downloads](https://img.shields.io/npm/dm/absolute-module-mapper-plugin.svg?style=flat-square\u0026maxAge=43200)](https://www.npmjs.com/package/absolute-module-mapper-plugin)\n[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://prettier.io/)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)\n\n\u003e The plugin on enhanced-resolver to map module path\n\nIt's helpful when we need to adjust third-party library dependencies. for example:\n\nWe have the follow project directory tree now.\n```text\nproject/\n   node_modules/\n      antd/\n         lib/\n            components/\n               icon/\n                  index.js\n               button/\n                  index.js  # requires icon/index.js\n               ... \n   wrapper/\n      button/\n         index.js\n      icon/\n         index.js\n```\n\nAnd the point is `antd/button` requires `antd/icon`, but we prefer it requires `wrapper/icon` which we can customize.\n\nSo we could use this plugin in webpack, let `antd/icon` in `antd/button` is mapped to `wrapper/icon`.\n\n## Installation\n\n```bash\nnpm install absolute-module-mapper-plugin\n# or use yarn\nyarn add absolute-module-mapper-plugin\n```\n\n## Usage in webpack\n\n```javascript\nconst AbsoluteModuleMapperPlugin = require('absolute-module-mapper-plugin')\n\nconst webpackConfig = {\n   resolve: {\n      plugins: [\n         new AbsoluteModuleMapperPlugin({\n            root: '/project',\n            include: [\n               '\u003croot\u003e/node_modules/antd/lib/components/button'\n            ],\n            mapper: {\n               '^\u003croot\u003e/node_modules/antd/lib/components/icon/index.js': '\u003croot\u003e/wrapper/icon/index.js'\n            }\n         })\n      ]\n   }\n}\n```\n\n## Options\n\n### `silent`\nShow some runtime log\n- Default: `true`\n\n### `root`\nAssign root path, it is the value for `\u003croot\u003e` placeholder.\n\n- Type: `string`\n\n### `include`\nThe included paths for mapping\n\n- Type: `Array\u003cstring|Function|RegExp\u003e`\n- Default: `[options.root]`\n\n### `exclude`\nThe excluded paths for mapping\n\n- Type: `Array\u003cstring|Function|RegExp\u003e`\n- Default: `[]`\n\n### `mapper`\n\nabsolute filename mapper.\n\n- Type: `(filename, ctx) =\u003e string | (filename, ctx, callback) =\u003e void  | {}`\n- Example\n```javascript\n{\n   '^\u003croot\u003e/from/(\\w+)': '\u003croot\u003e/to/$1'\n}\n```\n\n### `requestMapper`\n\nrequest mapper.\n\n- Type: `(request, ctx) =\u003e string | (request, ctx, callback) =\u003e void | {}`\n- Example\n```javascript\n{\n   '^./a.js$': './b.js'\n}\n```\n\n## Contributing\n\n- Fork it!\n- Create your new branch:  \n  `git checkout -b feature-new` or `git checkout -b fix-which-bug`\n- Start your magic work now\n- Make sure npm test passes\n- Commit your changes:  \n  `git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`\n- Push to the branch: `git push`\n- Submit a pull request :)\n\n## Authors\n\nThis library is written and maintained by imcuttle, \u003ca href=\"mailto:moyuyc95@gmail.com\"\u003emoyuyc95@gmail.com\u003c/a\u003e.\n\n## License\n\nMIT - [imcuttle](https://github.com/imcuttle) 🐟\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fabsolute-module-mapper-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimcuttle%2Fabsolute-module-mapper-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fabsolute-module-mapper-plugin/lists"}