{"_id":"@rollup/plugin-alias@6.0.1","bugs":{"url":"https://github.com/rollup/plugins/issues"},"bump":1,"dist":{"shasum":"3310f4627406f607d039244a4f2b3811c5636222","tarball":"http://registry-npm.ywwl.com/@rollup/plugin-alias/download/@rollup/plugin-alias-6.0.1.tgz","fileCount":5,"integrity":"sha512-08wjv2HEuyxIuriLELnksoX+so83XnJ5E4hbVeCHkWlwOcaRQaHYxpUTAplnZjrlh/l5mZgvH1itNC9kcTfTTA==","signatures":[{"sig":"MEUCIHHKJbm+QyYsI9x25vM4jO117OXVX36rAr79N8EHy0e2AiEA2PNzdfqbZVwnFnvaR0WLZGAxJYdmmHf2xVbOGEa2NhM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD2/ggE6KPnuF0T/thXSi/7xQXreELFrk3oh8m1Hwz2ZAIhAOHy4mWeaUws//ax6Nzz55nt7pwWMo69GTVTXOIjSXIz"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@rollup%2fplugin-alias@6.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":13979,"size":5414,"noattachment":false,"key":"/@rollup/plugin-alias/-/@rollup/plugin-alias-6.0.1.tgz"},"name":"@rollup/plugin-alias","type":"module","_from":"file:/tmp/versioner-pack-Co6dFn/rollup-plugin-alias-6.0.1.tgz","types":"./dist/index.d.ts","author":{"name":"Johannes Stein"},"engines":{"node":">=20.19.0"},"exports":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"license":"MIT","scripts":{"test":"vitest --config ../../.config/vitest.config.mts run","build":"tsc --project tsconfig.json","ci:lint":"pnpm build && pnpm lint","ci:test":"pnpm test -- --reporter=verbose","pretest":"pnpm build","release":"pnpm --workspace-root package:release $(pwd)","prebuild":"del-cli dist","prerelease":"pnpm build","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}"},"version":"6.0.1","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"d0f1d1c9-b153-44ae-96b2-0ad1f421c5ee"}},"homepage":"https://github.com/rollup/plugins/tree/master/packages/alias#readme","keywords":["rollup","plugin","resolve","alias","rollup-plugin"],"_resolved":"/tmp/versioner-pack-Co6dFn/rollup-plugin-alias-6.0.1.tgz","_integrity":"sha512-08wjv2HEuyxIuriLELnksoX+so83XnJ5E4hbVeCHkWlwOcaRQaHYxpUTAplnZjrlh/l5mZgvH1itNC9kcTfTTA==","repository":{"url":"git+https://github.com/rollup/plugins.git","directory":"packages/alias"},"_npmVersion":"11.5.1","description":"Define and resolve aliases for bundle dependencies","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"}],"_nodeVersion":"24.22.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.0.0","del-cli":"^5.0.0","typescript":"catalog:","@rollup/plugin-node-resolve":"^15.0.0"},"peerDependencies":{"rollup":">=4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-alias_6.0.1_1792597252851_0.1897628626542267"},"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":1792597252943,"_cnpm_publish_time":1792597252943,"dist-tags":{"latest":"6.0.1"}}