Define aliases when bundling packages with Rollup.
Let's take a simple import as an example:
This probably doesn't look too bad on its own. But imagine this is not the only instance in your code base and after a refactor/restructuring this might fall over. With this plugin in place, you can alias
something for readability. In case of a refactor only the alias would need to be changed instead of navigating through the code base and changing all imports.
When we write tests, we may want an easier way to access the local library we are testing or mocking libraries. We may also define aliases to counteract "require hell" and get rid of all those
../../../ imports we may have in the process.
For Webpack users: This is a plugin to mimic the
resolve.alias functionality in Rollup.
$ npm install rollup-plugin-alias
// rollup.config.js;input: './src/index.js'plugins:;// or with object syntaxinput: './src/index.js'plugins:;
The order of the entries is important, in that the first rules are applied first.
You can use either simple Strings or Regular Expressions to search in a more distinct and complex manner (e.g. to do partial replacements via subpattern-matching, see aboves example).
LICENSE for more information