rollup-plugin-file
raw JSON → 0.1.1 verified Mon Apr 27 auth: no javascript abandoned
Rollup plugin that allows a file object (e.g., from Gulp) to be used as an entry point, supporting vinyl files with a `base` property. Current version 0.1.1 is an early release with no tests, no updates since 2017, and no maintenance. Differentiates from standard Rollup entry by accepting file objects rather than file paths, primarily for integration with Gulp streams. Likely abandoned; caution advised for production use.
Common errors
error Error: The `entry` option must be a string, string array, or an object with a `base` property. ↓
cause Passing a string path instead of a file object with `base`.
fix
Use a vinyl file object from Gulp or manually add
base property to the file object. error TypeError: Cannot read property 'resolveId' of undefined ↓
cause Plugin not included in plugins array or Rollup version incompatible.
fix
Add rollupFile() to plugins array; check Rollup version compatibility (0.x only).
Warnings
breaking The package has no tests, no maintenance since 2017, and is likely abandoned. ↓
fix Consider alternative plugins like @rollup/plugin-url or rollup-plugin-stream
gotcha The entry file must have a `base` property (e.g., vinyl file from Gulp). Using a string path will fail. ↓
fix Ensure you pass a file object with `base` set, or use gulp-rollup-file wrapper
gotcha The plugin does not support modern Rollup versions (>=1.0.0); it only works with Rollup 0.x. ↓
fix Use with Rollup 0.x or find alternative for Rollup 1+
Install
npm install rollup-plugin-file yarn add rollup-plugin-file pnpm add rollup-plugin-file Imports
- default wrong
const rollupFile = require('rollup-plugin-file').defaultcorrectimport rollupFile from 'rollup-plugin-file' - rollupFile
import rollupFile from 'rollup-plugin-file' - plugin wrong
const rollupFile = require('rollup-plugin-file'); // missing .defaultcorrectimport rollupFile from 'rollup-plugin-file'; // then use in plugins: [rollupFile()]
Quickstart
import { rollup } from 'rollup';
import rollupFile from 'rollup-plugin-file';
import gulp from 'gulp';
import through from 'through2';
gulp.task('build', function() {
return gulp.src('./src/*.js')
.pipe(through.obj(function(file, enc, done) {
rollup({
entry: file,
plugins: [rollupFile()]
}).then(bundle => {
file.contents = Buffer.from(bundle.generate({format: 'iie'}).code);
done(null, file);
}).catch(done);
}))
.pipe(gulp.dest('./dist'));
});