Registry / gcp / rollup-plugin-google-apps-script

rollup-plugin-google-apps-script

JSON →
library2.0.2jsnpmunverified

Rollup plugin for Google Apps Script that generates top-level function declarations from global object assignments, enabling local development with modern bundlers and deployment via clasp. Current stable version 2.0.2, with support for Rollup ^3.25.0 || ^4.0.0 and Vite ^4.4.9. Maintained by mato533, inspired by gas-webpack-plugin. Releases are occasional; latest includes dependency updates and gas-entry-generator options. Key differentiators: works with both Rollup and Vite, generates GAS-compatible bundle structure, supports TypeScript out of the box.

npm install rollup-plugin-google-apps-script
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-GOOG
R
rollup-plugin-google-apps-script
gcpjavascriptv2.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gasPlugin
import gasPlugin from 'rollup-plugin-google-apps-script'
const gasPlugin = require('rollup-plugin-google-apps-script')
ESM-only module; does not provide a CommonJS export. Use import syntax.
gasPlugin
import gasPlugin from 'rollup-plugin-google-apps-script'
import { gasPlugin } from 'rollup-plugin-google-apps-script'
Default export only; named export gasPlugin does not exist.
GasPluginOptions
import type { GasPluginOptions } from 'rollup-plugin-google-apps-script'
import { GasPluginOptions } from 'rollup-plugin-google-apps-script'
TypeScript type export; use type-only import to avoid runtime errors.

Configures Vite with the gas plugin, setting input file, output directory, and GAS-specific options like manifest copy and entry generator settings.

import gasPlugin from 'rollup-plugin-google-apps-script'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ gasPlugin({ include: ['**/*.js'], moduleHeaderComment: true, manifest: { copy: true, srcDir: 'src', }, gasEntryOptions: { comment: true, autoGlobalExports: false, exportsIdentifierName: 'exports', globalIdentifierName: 'global', }, verbose: true, }), ], build: { outDir: 'dist', rollupOptions: { input: 'src/main.js', output: { format: 'esm', entryFileNames: 'bundle.js', }, }, }, });
Debug
Known issues
breakingMajor version v2.0.0 introduces gasEntryOptions and restructures option object; old top-level options like comment are deprecated.
fix
Move comment option under gasEntryOptions.comment; see migration guide.
affects: >=2.0.0
deprecatedThe top-level 'comment' option is deprecated in v2.0.0.
fix
Use gasEntryOptions.comment instead.
affects: >=2.0.0
gotchaPlugin generates top-level function declarations only for assignments to a property of the 'global' object (e.g., global.myFunc = ...). Other patterns are ignored.
fix
Ensure all GAS-entry functions are assigned as global.property = ...
affects: >=1.0.0
gotchaRequires import using ESM syntax; CommonJS require() will throw an error (module not found).
fix
Use import gasPlugin from 'rollup-plugin-google-apps-script'
affects: >=2.0.0
gotchaWhen using Vite, ensure Vite version ^4.4.9 is used; older versions may have compatibility issues.
fix
Upgrade Vite to ^4.4.9 or later.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'rollup-plugin-google-apps-script'
CommonJS require() used instead of ESM import.
fix
Use import gasPlugin from 'rollup-plugin-google-apps-script'
TypeError: gasPlugin is not a function
Named import used instead of default import.
fix
Use import gasPlugin from 'rollup-plugin-google-apps-script' (not import { gasPlugin })
You assigned to global but no top-level function was generated
Function not assigned as global.property, or file not included in the include pattern.
fix
Ensure assignment is like global.myFunc = () => {} and include pattern covers the file.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: required as the bundler that the plugin extends.
viteoptionalPeer dependency: required when using with Vite; optional if only Rollup is used.
Agent activity
37 hits · last 30 days
node
34
OpenAI (training)
2
Resources
rollup-plugin-google-apps-script — npm install rollup-plugin-google-apps-script · libregistry