rollup-plugin-resolve-id
Rollup plugin for resolves module by using aliases and file extensions, Also resolves the file when importing a directory. Migrate from rollup-plugin-resolve2
(sync with webpack resolve specs)
Install
yarn add --dev rollup-plugin-resolve-id
Options
; ; // if called without options, the defaults aredefaultOptions = 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
Resolve "index" file if import points to a directory
// src/index.js ; // resolved to ./utils/index.js
Resolve extensions
// src/utils/index.js ; // resolved to ./util1.js; // resolved to ./util2.jsm ;
Resolve aliases
// src/utils/util1.js ;// resolved to ./node_modules/other_lib/src/index.js ;// resolved to ./node_modules/other_lib/src/component1.js// OR if component1 is a folder ./node_modules/other_lib/src/component1/index.js