rollup-plugin-match
raw JSON → 1.0.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that matches input files using glob patterns via fast-glob. Version 1.0.0 is stable with no recent updates. It integrates with Rollup to allow flexible file matching, often used in conjunction with other plugins like rollup-plugin-empty to generate multiple output chunks. Differentiators: simple API, leverages fast-glob performance, and minimal configuration.
Common errors
error Error: Cannot find module 'rollup-plugin-match' ↓
cause Package not installed or missing from node_modules.
fix
npm install rollup-plugin-match --save-dev
error TypeError: match is not a function ↓
cause Importing as named export instead of default.
fix
Use const match = require('rollup-plugin-match') instead of const { match } = require(...)
error The plugin 'rollup-plugin-match' is not compatible with your Rollup version. Please update Rollup or the plugin. ↓
cause Incompatible Rollup version (likely too old).
fix
Update Rollup: npm install rollup@latest --save-dev
Warnings
gotcha The match plugin must be placed after plugins that generate files (like empty) because it matches files from the input glob, not virtual modules. ↓
fix Ensure match() is after file-generating plugins in the plugins array.
gotcha The plugin uses fast-glob under the hood; options passed to match() are directly forwarded to fast-glob. Not all Rollup input options are supported. ↓
fix Refer to fast-glob documentation for available options.
deprecated The plugin does not support Rollup's new 'output.manualChunks' or 'preserveModules' directly; it works with basic input globs. ↓
fix Consider using official Rollup code splitting or manual chunks for complex scenarios.
Install
npm install rollup-plugin-match yarn add rollup-plugin-match pnpm add rollup-plugin-match Imports
- default wrong
const { match } = require('rollup-plugin-match');correctconst match = require('rollup-plugin-match'); module.exports = { plugins: [match()] } - default (ESM) wrong
import { match } from 'rollup-plugin-match';correctimport match from 'rollup-plugin-match'; - match (as function) wrong
new match() or match.create()correctconst match = require('rollup-plugin-match'); match()
Quickstart
// rollup.config.js
const match = require('rollup-plugin-match');
const empty = require('rollup-plugin-empty');
module.exports = {
input: 'src/**/*.js',
plugins: [
empty({ silent: false, dir: 'dist' }),
match() // matches files based on input glob
],
output: {
dir: 'dist',
format: 'es',
entryFileNames: '[name].js'
}
};