Rollup Scripts
Rollup Scripts is a zero-configuration compiler and bundler designed for JavaScript and TypeScript libraries, wrapping Rollup's core functionality to eliminate manual setup. It provides out-of-the-box support for JS, TS, React, and Preact projects. Currently at version 0.0.131, it is explicitly marked as experimental and in active development, meaning versions are unstable and intended for trial purposes only. Its primary differentiator is simplifying the build process by abstracting Rollup configurations, reducing boilerplate for library authors. Future updates are planned to extend support to Angular, Vue, and Svelte.
Common errors
-
command not found: rollup-scripts
cause The 'rollup-scripts' executable is not in the system's PATH or not accessible in the current project context.fixEnsure 'rollup-scripts' is installed as a dev dependency ('npm i -D rollup-scripts') and run it via 'npx rollup-scripts <command>' or through an npm script defined in package.json (e.g., 'npm run build'). -
Error: No entry file found for compilation.
cause Rollup Scripts could not locate a default entry file (e.g., 'src/index.mjs', 'src/index.js', 'src/index.ts') or the `package.json` 'main'/'module' fields are misconfigured for the intended output.fixVerify that a supported entry file exists in your 'src' directory (e.g., 'src/index.mjs') and that your `package.json` 'main' and 'module' fields correctly point to the intended output paths and file types.
Warnings
- breaking This package is explicitly experimental and in active development. Version 0.0.x is unstable and should only be used for trial purposes. Breaking changes are frequent and without prior notice.
- gotcha Do not install this package globally. It is designed to be installed as a local development dependency to ensure project-specific versioning and avoid conflicts.
- gotcha Rollup Scripts enforces a 'zero config' approach, which means it expects specific file structures and `package.json` configurations (e.g., 'src/index.mjs' as an entry, 'main'/'module' fields) to function correctly.
Install
-
npm install rollup-scripts -
yarn add rollup-scripts -
pnpm add rollup-scripts
Imports
- rollup-scripts executable
import rollupScripts from 'rollup-scripts'
npx rollup-scripts <command>
- build script
"build": "node_modules/.bin/rollup-scripts build"
"build": "rollup-scripts build"
Quickstart
# 1. Create an npm project
npm init -y
# 2. Install rollup-scripts as a dev dependency
npm i -D --save-exact rollup-scripts
# 3. Create a source directory and an entry file
mkdir src
echo "export const greet = (name) => \`Hello, \${name} from Rollup Scripts!\`;\nexport const PI = 3.14159;" > src/index.mjs
# 4. Manually update your package.json file.
# Ensure it looks similar to this, especially the 'main', 'module', and 'scripts' sections:
# {
# "name": "my-library-with-rollup-scripts",
# "version": "1.0.0",
# "main": "dist/umd/index.js",
# "module": "dist/esm/index.mjs",
# "scripts": {
# "build": "rollup-scripts build",
# "lint": "rollup-scripts lint",
# "init": "rollup-scripts init"
# },
# "devDependencies": {
# "rollup-scripts": "^0.0.131" // Adjust version as necessary
# }
# }
# 5. Run the build command
npm run build
# After successful build, verify the output (e.g., check 'dist' folder).
# Example of using the built UMD module:
# node -e "const { greet } = require('./dist/umd/index.js'); console.log(greet('AI Agent'));"