Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kei-ito/rollup-plugin-glob-import
A rollup plugin to use glob-star.
https://github.com/kei-ito/rollup-plugin-glob-import
glob rollup
Last synced: 2 months ago
JSON representation
A rollup plugin to use glob-star.
- Host: GitHub
- URL: https://github.com/kei-ito/rollup-plugin-glob-import
- Owner: gjbkz
- License: mit
- Created: 2017-04-08T08:18:04.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T11:48:58.000Z (8 months ago)
- Last Synced: 2024-05-01T16:05:12.289Z (7 months ago)
- Topics: glob, rollup
- Language: JavaScript
- Homepage:
- Size: 2.24 MB
- Stars: 22
- Watchers: 1
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome - glob-import - Glob support for import statements. (Plugins / Modules)
README
# rollup-plugin-glob-import
[![.github/workflows/test.yml](https://github.com/gjbkz/rollup-plugin-glob-import/actions/workflows/test.yml/badge.svg)](https://github.com/gjbkz/rollup-plugin-glob-import/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/kei-ito/rollup-plugin-glob-import/branch/master/graph/badge.svg)](https://codecov.io/gh/kei-ito/rollup-plugin-glob-import)A plugin to use glob-star in import source.
```javascript
import foo from './path/to/lib/*.js';
```## Installation
```bash
npm install --save-dev rollup-plugin-glob-import
```## Usage
```javascript
// rollup.config.js
const globImport = require('rollup-plugin-glob-import');
// import {plugin as globImport} from 'rollup-plugin-glob-import';
export default {
input: 'path/to/input.js',
plugins: [
globImport(options) // See the "Options" section below.
]
}
```## Example
- [sample/001](sample/001): Import named exports
- [sample/002](sample/002): Import all exports including default exports
- [sample/003](sample/003): Import side effects
- [sample/004](sample/004): Use options.rename## Options
```typescript
export interface IGlobPluginOptions {
/**
* The first argument of [rollup-pluginutils.createfilter](https://github.com/rollup/rollup-pluginutils#createfilter).
*/
include?: Parameters[0],
/**
* The second argument of [rollup-pluginutils.createfilter](https://github.com/rollup/rollup-pluginutils#createfilter).
*/
exclude?: Parameters[0],
/**
* - `'import'`: The intermediate files work as importer that export nothing.
* - `'named'`: The intermediate files export only **named** exports.
* - `'default'`: The intermediate files export only **default** exports.
* - `'mixed'`: This plugin read the imported files and parse it with
* [acorn](https://www.npmjs.com/package/acorn) to check default exports.
* Intermediate files export both named exports and default exports.
*/
format?: IntermediateFileFormat,
/**
* A function generates the name of exports.
* It is used if `options.format` is `'mixed'` or `'default'`.
* For example, if an imported module `/src/foo.js` has
* `export const bar = 123` and `export default 456`, it is called twice:
* `rename('bar', '/src/foo.js')`, `rename(null, '/src/foo.js')`.
* If a return values is falsy value, it is ignored.
*/
rename?: (name: string, id: string) => string,
/**
* [acorn](https://www.npmjs.com/package/acorn) options.
* The default value is `{sourceType: 'module'}`.
*/
acorn?: acorn.Options,
/**
* A function called before generating intermediate files.
* You can add or remove files from sources.
*/
intercept?: (sources: Array, importer: string, importee: string) => Array,
}
```https://github.com/kei-ito/rollup-plugin-glob-import/blob/d5d6d22d322da92ca8026322b2d629689fd8496d/lib/index.d.ts#L12-L49
## License
MIT