rollup-plugin-gas
raw JSON → 1.0.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that bundles JavaScript/TypeScript code into a single file compatible with Google Apps Script (GAS). Version 1.0.0 is stable; no release cadence documented. It transpiles imports/exports (ES modules) into a single script with a global namespace, which is required by GAS as it does not support modules natively. Key differentiator: integrates tightly with Rollup's build pipeline. Compared to alternatives like clasp or gas-webpack-plugin, it leverages Rollup's tree-shaking and plugin ecosystem.
Common errors
error Error: Cannot find module 'rollup-plugin-gas' ↓
cause Package not installed or incorrect import path.
fix
npm install rollup-plugin-gas --save-dev and ensure import path is 'rollup-plugin-gas'.
error TypeError: gas is not a function ↓
cause Importing as named import instead of default.
fix
Use import gas from 'rollup-plugin-gas' (default import).
error Error: Unexpected token 'export' ↓
cause Using require() with ESM module or not transpiling ES modules before bundling.
fix
Ensure your Rollup config uses format: 'esm' or 'iife', and that you are not using require() in your code.
Warnings
gotcha The plugin does not support TypeScript natively. You must use @rollup/plugin-typescript or similar before gas(). ↓
fix Add @rollup/plugin-typescript to plugins array before gas().
breaking Version 1.0.0 changed from CommonJS to ESM. require() usage will break. ↓
fix Use dynamic import() or switch to ESM configuration.
gotcha The plugin only works with Rollup 1.x or higher. Older Rollup versions are incompatible. ↓
fix Update Rollup to version 1.x or later.
gotcha Does not handle dynamic imports; they are left as-is and will fail at runtime in GAS. ↓
fix Avoid dynamic import() statements in your source code, or use a different plugin to replace them.
Install
npm install rollup-plugin-gas yarn add rollup-plugin-gas pnpm add rollup-plugin-gas Imports
- gas wrong
const gas = require('rollup-plugin-gas')correctimport gas from 'rollup-plugin-gas' - gas (default import) wrong
import { gas } from 'rollup-plugin-gas'correctimport gas from 'rollup-plugin-gas' - Plugin type wrong
import { Plugin } from 'rollup-plugin-gas'correctimport type { Plugin } from 'rollup'
Quickstart
// rollup.config.js
import gas from 'rollup-plugin-gas';
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'esm' // or 'iife' – rolled into single file
},
plugins: [gas()]
};