All Projects → rollup → Rollup Plugin Alias

rollup / Rollup Plugin Alias

Licence: mit
This module has moved and is now available at @rollup/plugin-alias / https://github.com/rollup/plugins

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Rollup Plugin Alias

Angular Seed Express
[DEPRECATED, Please use https://github.com/vyakymenko/angular-express] Extensible, reliable and modular starter project for Angular 7 with statically typed build AoT compilation, Express server and PM2 Daemon.
Stars: ✭ 107 (-38.86%)
Mutual labels:  rollup
Callapp Lib
🔥call app from h5(H5唤起客户端 )
Stars: ✭ 1,857 (+961.14%)
Mutual labels:  rollup
Workflow
一个工作流平台
Stars: ✭ 1,888 (+978.86%)
Mutual labels:  rollup
Sketchmine
Tools to validate, generate and analyse sketch files from web pages
Stars: ✭ 114 (-34.86%)
Mutual labels:  rollup
Eleventy Starter
ARCHIVED: An Eleventy starting point with Tailwind and Svelte preconfigured.
Stars: ✭ 118 (-32.57%)
Mutual labels:  rollup
Rollup Plugin Copy
Copy files and folders using Rollup
Stars: ✭ 128 (-26.86%)
Mutual labels:  rollup
Moderndeck
A beautiful, powerful Twitter client for desktop.
Stars: ✭ 100 (-42.86%)
Mutual labels:  rollup
Tails Ui
🐒 Clean UI based on tailwindcss
Stars: ✭ 162 (-7.43%)
Mutual labels:  rollup
Example Rollup React Component Npm Package
Example React Component, Published to npm
Stars: ✭ 122 (-30.29%)
Mutual labels:  rollup
React Border Wrapper
A wrapper for placing elements along div borders.
Stars: ✭ 147 (-16%)
Mutual labels:  rollup
Babel Plugin Prismjs
A babel plugin to use PrismJS with standard bundlers.
Stars: ✭ 114 (-34.86%)
Mutual labels:  rollup
Rollup Plugin Styles
🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
Stars: ✭ 116 (-33.71%)
Mutual labels:  rollup
Plugins
🍣 The one-stop shop for official Rollup plugins
Stars: ✭ 2,238 (+1178.86%)
Mutual labels:  rollup
Cjstoesm
A tool that can transform CommonJS to ESM
Stars: ✭ 109 (-37.71%)
Mutual labels:  rollup
Rollupjs Note
《Rollup.js 实战学习笔记》已完结 😆
Stars: ✭ 152 (-13.14%)
Mutual labels:  rollup
Vue Example
Vue.js Examples
Stars: ✭ 105 (-40%)
Mutual labels:  rollup
Babel React Rollup Starter
A simple boilerplate for web apps with React, Babel, and Rollup.
Stars: ✭ 124 (-29.14%)
Mutual labels:  rollup
Js Sdk
JavaScript & Node.js SDKs for the Elastic Path Commerce Cloud eCommerce API
Stars: ✭ 169 (-3.43%)
Mutual labels:  rollup
React Rollup Boilerplate
Boilerplate for creating React component libraries, bundled with Rollup.js to ES6 Modules, React Styleguidist, Typescript
Stars: ✭ 157 (-10.29%)
Mutual labels:  rollup
Klap
zero config, zero dependency bundler for tiny javascript packages
Stars: ✭ 143 (-18.29%)
Mutual labels:  rollup

Moved

This module has moved and is now available at @rollup/plugin-alias. Please update your dependencies. This repository is no longer maintained.

rollup-plugin-alias

Define aliases when bundling packages with Rollup.

Build Status Dependency Status devDependency Status Coverage Status

Let's take a simple import as an example:

import something from '../../../something';

something();

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 with 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.

import something from 'something';

something();

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.

Installation

$ npm install rollup-plugin-alias

Usage

// rollup.config.js
import alias from 'rollup-plugin-alias';

export default {
  input: './src/index.js',
  plugins: [
    alias({
      resolve: ['.jsx', '.js'], //optional, by default this will just look for .js files or folders
      entries:[
        {find:'something', replacement: '../../../something'}, //the initial example
        {find:'somelibrary-1.0.0', replacement: './mylocallibrary-1.5.0'}, //remap a library with a specific version
        {find:/^i18n\!(.*)/, replacement: '$1.js'}, //remove something in front of the import and append an extension (e.g. loaders, for files that were previously transpiled via the AMD module, to properly handle them in rollup as internals now)
        //for whatever reason, replace all .js extensions with .wasm
        {find:/^(.*)\.js$/, replacement: '$1.wasm'}
      ]
    })
  ],
};

// or with object syntax
export default {
  input: './src/index.js',
  plugins: [
    alias({
      resolve: ['.jsx', '.js'],
      entries: {
        something: '../../../something',
        'somelibrary-1.0.0': './mylocallibrary-1.5.0',
      }
    })
  ],
};

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

MIT, see LICENSE for more information

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].