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.

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.
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.
npm install rollup-plugin-gas
yarn add rollup-plugin-gas
pnpm add rollup-plugin-gas

Shows how to configure Rollup with rollup-plugin-gas to bundle a JS file for Google Apps Script.

// 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()]
};