{"name":"@rollup/plugin-alias","version":"6.0.0","publishConfig":{"access":"public"},"description":"Define and resolve aliases for bundle dependencies","license":"MIT","repository":{"url":"git+https://github.com/rollup/plugins.git","directory":"packages/alias"},"author":{"name":"Johannes Stein"},"homepage":"https://github.com/rollup/plugins/tree/master/packages/alias#readme","bugs":{"url":"https://github.com/rollup/plugins/issues"},"type":"module","exports":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"engines":{"node":">=20.19.0"},"keywords":["rollup","plugin","resolve","alias"],"peerDependencies":{"rollup":">=4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"devDependencies":{"@rollup/plugin-node-resolve":"^15.0.0","del-cli":"^5.0.0","rollup":"^4.0.0","typescript":"catalog:"},"types":"./dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint":"pnpm build && pnpm lint","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}","ci:test":"pnpm test -- --reporter=verbose","prebuild":"del-cli dist","prerelease":"pnpm build","pretest":"pnpm build","release":"pnpm --workspace-root package:release $(pwd)","test":"vitest --config ../../.config/vitest.config.mts run"},"_id":"@rollup/plugin-alias@6.0.0","_integrity":"sha512-tPCzJOtS7uuVZd+xPhoy5W4vThe6KWXNmsFCNktaAh5RTqcLiSfT4huPQIXkgJ6YCOjJHvecOAzQxLFhPxKr+g==","_resolved":"/tmp/654ca1ea4374bb6210e9608f15a2515a/rollup-plugin-alias-6.0.0.tgz","_from":"file:rollup-plugin-alias-6.0.0.tgz","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-tPCzJOtS7uuVZd+xPhoy5W4vThe6KWXNmsFCNktaAh5RTqcLiSfT4huPQIXkgJ6YCOjJHvecOAzQxLFhPxKr+g==","shasum":"f7fa8c806db9c073baa6b00e4b1c396edef9beb2","tarball":"http://registry-npm.ywwl.com/@rollup/plugin-alias/download/@rollup/plugin-alias-6.0.0.tgz","fileCount":5,"unpackedSize":13572,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEZ32OH/1blutUzvL+3Yr0EGBcVd9O4F5OrTT6WHUolnAiA9xstoOIs94GR+FN5uAQwmVlUlQkFcujrW3MP6ytjw9w=="}],"size":5274,"noattachment":false,"key":"/@rollup/plugin-alias/-/@rollup/plugin-alias-6.0.0.tgz"},"_npmUser":{"name":"shellscape","email":"andrew@shellscape.org"},"directories":{},"maintainers":[{"name":"shellscape","email":"andrew@shellscape.org"},{"name":"rich_harris","email":"richard.a.harris@gmail.com"},{"name":"guybedford","email":"guybedford@gmail.com"},{"name":"lukastaegert","email":"lukas.taegert@tngtech.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-alias_6.0.0_1761672902023_0.8291855040787697"},"_hasShrinkwrap":false,"readme":"[npm]: https://img.shields.io/npm/v/@rollup/plugin-alias\n[npm-url]: https://www.npmjs.com/package/@rollup/plugin-alias\n[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-alias\n[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-alias\n\n[![npm][npm]][npm-url]\n[![size][size]][size-url]\n[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)\n\n# @rollup/plugin-alias\n\n🍣 A Rollup plugin for defining aliases when bundling packages.\n\n## Alias 101\n\nSuppose we have the following `import` defined in a hypothetical file:\n\n```javascript\nimport batman from '../../../batman';\n```\n\nThis probably doesn't look too bad on its own. But consider that may not be the only instance in your codebase, and that after a refactor this might be incorrect. With this plugin in place, you can alias `../../../batman` with `batman` for readability and maintainability. In the case of a refactor, only the alias would need to be changed, rather than navigating through the codebase and changing all imports.\n\n```javascript\nimport batman from 'batman';\n```\n\nIf this seems familiar to Webpack users, it should. This is plugin mimics the `resolve.extensions` and `resolve.alias` functionality in Webpack.\n\nThis plugin will work for any file type that Rollup natively supports, or those which are [supported by third-party plugins](https://github.com/rollup/awesome#other-file-imports).\n\n## Requirements\n\nThis plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.\n\n## Install\n\nUsing npm:\n\n```console\nnpm install @rollup/plugin-alias --save-dev\n# or\nyarn add -D @rollup/plugin-alias\n```\n\n## Usage\n\nCreate a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:\n\n```js\nimport alias from '@rollup/plugin-alias';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'cjs'\n  },\n  plugins: [\n    alias({\n      entries: [\n        { find: 'utils', replacement: '../../../utils' },\n        { find: 'batman-1.0.0', replacement: './joker-1.5.0' }\n      ]\n    })\n  ]\n};\n```\n\nThen call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api). If the build produces any errors, the plugin will write a 'alias' character to stderr, which should be audible on most systems.\n\n## Options\n\n### `customResolver`\n\nType: `Function | Object`<br>\nDefault: `null`\n\nInstructs the plugin to use an alternative resolving algorithm, rather than the Rollup's resolver. Please refer to the [Rollup documentation](https://rollupjs.org/guide/en/#resolveid) for more information about the `resolveId` hook. For a detailed example, see: [Custom Resolvers](#custom-resolvers).\n\n### `entries`\n\nType: `Object | Array[...Object]`<br>\nDefault: `null`\n\nSpecifies an `Object`, or an `Array` of `Object`, which defines aliases used to replace values in `import` or `require` statements. With either format, the order of the entries is important, in that the first defined rules are applied first. This option also supports [Regular Expression Alias](#regular-expression-aliases) matching.\n\n_Note: Entry targets (the object key in the Object Format, or the `find` property value in the Array Format below) should not end with a trailing slash in most cases. If strange behavior is observed, double check the entries being passed in options._\n\n#### `Object` Format\n\nThe `Object` format allows specifying aliases as a key, and the corresponding value as the actual `import` value. For example:\n\n```js\nalias({\n  entries: {\n    utils: '../../../utils',\n    'batman-1.0.0': './joker-1.5.0'\n  }\n});\n```\n\n#### `Array[...Object]` Format\n\nThe `Array[...Object]` format allows specifying aliases as objects, which can be useful for complex key/value pairs.\n\n```js\nentries: [\n  { find: 'utils', replacement: '../../../utils' },\n  { find: 'batman-1.0.0', replacement: './joker-1.5.0' }\n];\n```\n\n## Regular Expression Aliases\n\nRegular Expressions can be used to search in a more distinct and complex manner. e.g. To perform partial replacements via sub-pattern matching.\n\nTo remove something in front of an import and append an extension, use a pattern such as:\n\n```js\n{ find:/^i18n\\!(.*)/, replacement: '$1.js' }\n```\n\nThis would be useful for loaders, and files that were previously transpiled via the AMD module, to properly handle them in rollup as internals.\n\nTo replace extensions with another, a pattern like the following might be used:\n\n```js\n{ find:/^(.*)\\.js$/, replacement: '$1.alias' }\n```\n\nThis would replace the file extension for all imports ending with `.js` to `.alias`.\n\n## Resolving algorithm\n\nThis plugin uses resolver plugins specified for Rollup and eventually Rollup default algorithm. If you rely on Node specific features, you probably want [@rollup/plugin-node-resolve](https://www.npmjs.com/package/@rollup/plugin-node-resolve) in your setup.\n\n## Custom Resolvers\n\nThe `customResolver` option can be leveraged to provide separate module resolution for an individual alias.\n\nExample:\n\n```javascript\n// rollup.config.js\nimport alias from '@rollup/plugin-alias';\nimport resolve from '@rollup/plugin-node-resolve';\n\nconst customResolver = resolve({\n  extensions: ['.mjs', '.js', '.jsx', '.json', '.sass', '.scss']\n});\nconst projectRootDir = path.resolve(__dirname);\n\nexport default {\n  // ...\n  plugins: [\n    alias({\n      entries: [\n        {\n          find: 'src',\n          replacement: path.resolve(projectRootDir, 'src')\n          // OR place `customResolver` here. See explanation below.\n        }\n      ],\n      customResolver\n    }),\n    resolve()\n  ]\n};\n```\n\nIn the example above the alias `src` is used, which uses the `node-resolve` algorithm for files _aliased_ with `src`, by passing the `customResolver` option. The `resolve()` plugin is kept separate in the plugins list for other files which are not _aliased_ with `src`. The `customResolver` option can be passed inside each `entries` item for granular control over resolving allowing each alias a preferred resolver.\n\n## Meta\n\n[CONTRIBUTING](/.github/CONTRIBUTING.md)\n\n[LICENSE (MIT)](/LICENSE)\n","publish_time":1761672902224,"_cnpm_publish_time":1761672902224,"dist-tags":{"latest":"6.0.1"}}