1. rollup-plugin-local-resolve
Resolves index.js files with Rollup
rollup-plugin-local-resolve
Package: rollup-plugin-local-resolve
Created by: frostney
Last modified: Sun, 26 Jun 2022 14:00:04 GMT
Version: 1.0.7
License: MIT
Downloads: 32,352
Repository: https://github.com/frostney/rollup-plugin-local-resolve

Install

npm install rollup-plugin-local-resolve
yarn add rollup-plugin-local-resolve

rollup-plugin-local-resolve

Resolves Node-style directories with index.js files in Rollup

Build Status Dependency Status devDependency Status Coverage Status

Rollup by default doesn't handle resolving ./folder to ./folder/index.js internally. While there is the rollup-plugin-node-resolve plugin which also resolves directories as well as all dependencies from the node_modules directory, these may sometimes be too much for the use case at hand.

Installation

npm install rollup-plugin-local-resolve

Usage

 import { rollup } from 'rollup';
import localResolve from 'rollup-plugin-local-resolve';

// This will resolve `./files` to `./files/index.js` if the file exists
rollup({
  entry: './files',
  plugins: [localResolve()],
});

Things to improve on

  • Check for index.js file asynchronously
  • Use absolute paths instead of relative ones to be consistent with how Rollup handles modules

License

MIT, see LICENSE for more information

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code