npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gas-plugin/unplugin

v0.1.2

Published

Universal bundler plugin for Google Apps Script projects (Vite, Rollup, Rolldown, webpack, esbuild, Bun)

Readme

@gas-plugin/unplugin

CI codecov npm Version License: MIT

A universal bundler plugin for Google Apps Script (GAS) projects. Works with Vite, Rollup, Rolldown, webpack, esbuild, and Bun.

What It Does

Google Apps Script requires plain top-level function declarations — no export keywords, no ES module syntax. This plugin bridges the gap between modern bundler output and what GAS expects:

  • Strips export keywords from function/class/variable declarations
  • Removes export { ... } blocks generated by bundlers
  • Prevents tree-shaking of GAS entry points (e.g., onOpen, doGet)
  • Copies appsscript.json manifest to the output directory
  • Copies additional files (HTML, JSON, etc.) via glob patterns

Install

# npm
npm install -D @gas-plugin/unplugin

# yarn
yarn add -D @gas-plugin/unplugin

# pnpm
pnpm add -D @gas-plugin/unplugin

Usage

Vite

// vite.config.ts
import gasPlugin from "@gas-plugin/unplugin/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [gasPlugin()],
  build: {
    lib: {
      entry: "src/main.ts",
      formats: ["es"],
      fileName: () => "Code.js",
    },
  },
});

Rollup

// rollup.config.js
import gasPlugin from "@gas-plugin/unplugin/rollup";

export default {
  input: "src/main.ts",
  output: { dir: "dist", format: "es" },
  plugins: [gasPlugin()],
};

webpack

// webpack.config.js
const gasPlugin = require("@gas-plugin/unplugin/webpack").default;

module.exports = {
  entry: "./src/main.ts",
  output: { path: __dirname + "/dist" },
  plugins: [gasPlugin()],
};

esbuild

import gasPlugin from "@gas-plugin/unplugin/esbuild";
import { build } from "esbuild";

await build({
  entryPoints: ["src/main.ts"],
  outdir: "dist",
  bundle: true,
  format: "esm",
  plugins: [gasPlugin()],
});

Rolldown

// rolldown.config.mjs
import gasPlugin from "@gas-plugin/unplugin/rolldown";

export default {
  input: "src/main.ts",
  output: { dir: "dist", format: "es" },
  plugins: [gasPlugin()],
};

Bun

import gasPlugin from "@gas-plugin/unplugin/bun";

await Bun.build({
  entrypoints: ["src/main.ts"],
  outdir: "dist",
  plugins: [gasPlugin()],
});

Options

interface GasPluginOptions {
  /**
   * Path to appsscript.json manifest file.
   * Resolved relative to the project root.
   * @default "appsscript.json"
   */
  manifest?: string;

  /**
   * Glob patterns for additional files to copy flat to the output directory.
   * Files are copied without subdirectory structure (basename only).
   * Duplicate basenames trigger a warning; the first match wins.
   * @default []
   */
  include?: string[];

  /**
   * Function names to explicitly protect from tree-shaking.
   * These functions will be kept as top-level declarations in the output,
   * even if they are not exported from the entry point.
   * @default []
   */
  globals?: string[];

  /**
   * When true (default), exported functions are automatically added to the
   * tree-shake protection list. When false, only functions explicitly listed
   * in `globals` are protected.
   * @default true
   */
  autoGlobals?: boolean;
}

Examples

Basic GAS Project

// vite.config.ts
import gasPlugin from "@gas-plugin/unplugin/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [gasPlugin()],
  build: {
    lib: {
      entry: "src/main.ts",
      formats: ["es"],
      fileName: () => "Code.js",
    },
  },
});

GAS Web App with HTML

// vite.config.ts
import gasPlugin from "@gas-plugin/unplugin/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [
    gasPlugin({
      include: ["src/**/*.html"],
      globals: ["getData", "saveData"],
    }),
  ],
  build: {
    lib: {
      entry: "src/main.ts",
      formats: ["es"],
      fileName: () => "Code.js",
    },
  },
});

How It Works

  1. Transform phase: Detects exported function declarations and injects tree-shake protection markers (globalThis.__gas_keep__) to prevent bundlers from removing GAS entry points.

  2. Post-process phase: After bundling, strips all export keywords and export { ... } blocks, removes the tree-shake protection markers, and normalizes trailing newlines.

  3. File copy phase: Copies appsscript.json and any files matching include patterns to the output directory.

Compatibility

| Bundler | Version | | -------- | -------------- | | Vite | >= 5.0.0 | | Rollup | >= 4.0.0 | | Rolldown | >= 1.0.0-rc.1 | | webpack | >= 5.0.0 | | esbuild | >= 0.17.0 | | Bun | latest |

Node.js: >= 20

License

MIT