npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-resolve2

v1.0.0

Published

Resolves import statements using aliases and file extensions, (sync with webpack resolve specs)

Downloads

8

Readme

rollup-plugin-resolve2

Resolves import statements by using aliases and file extensions when bundling with rollup. Also resolves the file when importing a directory. Based on rollup-plugin-import-resolver (sync with webpack resolve specs)

Install

yarn add --dev rollup-plugin-resolve2

# OR

npm install --save-dev rollup-plugin-resolve2

Options

import importResolver from "rollup-plugin-resolve2";

importResolver({
  // a list of file extensions to check, default = ['.js']
  extensions: ['.js', '.vue'],
  // a list of aliases, default = {}
  alias: {
      'lib': './node_modules/otherlib/src'
  },
  // index file name without extension, default = 'index'
  indexFile: 'index'
});

// if called without options, the defaults are
defaultOptions = {
  extensions: ['js'],
  alias: {},
  indexFile: 'index'
};

Usage scenarios

Consider the following project structure

|-- .. 
'-- src
   |-- ..
   |-- index.js
   '-- utils
       |-- ..
       |-- util1.js
       |-- util2.jsm
       '-- index.js

and plugin options

{
    "extensions": [".js", ".jsm"],
    "alias": {
        "somelib": "./node_modules/other_lib/src/"
    }
}

Resolve "index" file if import points to a directory

// src/index.js

import * as utils from "./utils"; 
// resolved to ./utils/index.js

Resolve extensions

// src/utils/index.js

import util1 from "./util1"; 
// resolved to ./util1.js
import util2 from "./util2"; 
// resolved to ./util2.jsm

export {util1 as u1, util2 as u2};

Resolve aliases

// src/utils/util1.js

import somelib from "somelib";
// resolved to ./node_modules/other_lib/src/index.js

import component1 from "somelib/component1";
// resolved to ./node_modules/other_lib/src/component1.js
// OR if component1 is a folder ./node_modules/other_lib/src/component1/index.js