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-vite-plugin

v0.0.4

Published

A minimal Vite plugin for Google Apps Script projects

Downloads

466

Readme

GAS Vite Plugin

A minimal Vite plugin for Google Apps Script (GAS) projects.

Write standard TypeScript with export function — the plugin handles the rest.

Features

  • Strips export keywords — top-level functions become callable by GAS
  • Copies appsscript.json to dist automatically
  • include option — copy HTML/CSS/images flat to dist for web apps
  • globals option — protect non-exported functions from tree-shaking
  • autoGlobals toggle — fine-grained control over tree-shake protection
  • Sets GAS-safe build defaults (no minification, no code splitting)
  • V8 runtime assumed — no unnecessary legacy transforms
  • No AST parser dependency — regex-based transforms

What this plugin does NOT do (by design)

  • Arrow function → function declaration conversion (V8 handles this)
  • console.logLogger.log conversion
  • Path alias detection (Vite's job)
  • TypeScript compilation (Vite's job via oxc/esbuild)

Install

npm install -D gas-vite-plugin

Usage

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

export default defineConfig({
  plugins: [gasPlugin()],
  build: {
    lib: {
      entry: "src/main.ts",
      formats: ["es"],
      fileName: () => "Code.js",
    },
  },
});
// src/main.ts
export function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu("My Menu")
    .addItem("Run", "myFunction")
    .addToUi();
}

export function myFunction() {
  SpreadsheetApp.getActiveSpreadsheet().toast("Hello!");
}
npx vite build
npx clasp push

Options

gasPlugin({
  manifest: "src/appsscript.json", // Path to manifest (default)
  include: ["src/**/*.html"],       // Copy additional files flat to dist
  globals: ["processData"],         // Protect functions from tree-shaking
  autoGlobals: true,                // Auto-protect exported functions (default)
});

include

Copy additional files (HTML, CSS, images) flat to the output directory. Essential for GAS web apps using HtmlService.createHtmlOutputFromFile().

gasPlugin({
  include: ["src/**/*.html", "src/**/*.css"],
});

Files are flattened — src/views/index.html becomes dist/index.html. Duplicate basenames trigger a warning.

globals

Protect non-exported functions from tree-shaking. Use for functions called by GAS via string name (menu handlers, trigger targets).

// vite.config.ts
gasPlugin({ globals: ["processData"] });

// src/main.ts
export function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu("Tools")
    .addItem("Run", "processData")  // GAS calls by string name
    .addToUi();
}

function processData() {  // Not exported, but protected by globals
  Logger.log("Processing...");
}

autoGlobals

When true (default), exported functions are automatically protected from tree-shaking. Set to false for explicit control — only functions in globals are protected.

gasPlugin({
  autoGlobals: false,
  globals: ["onOpen", "doGet"],
});

Web App Example

// vite.config.ts
import gasPlugin from "gas-vite-plugin";
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",
    },
  },
});
// src/main.ts
export function doGet() {
  return HtmlService.createHtmlOutputFromFile("index").setTitle("My App");
}

// Called by client via google.script.run — protected by globals config
function getData() {
  return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getDataRange().getValues();
}
<!-- src/index.html (copied flat to dist via include) -->
<!DOCTYPE html>
<html>
  <body>
    <div id="app"></div>
    <script>
      google.script.run.withSuccessHandler(console.log).getData();
    </script>
  </body>
</html>

Project Structure

your-gas-project/
├── src/
│   ├── main.ts            # Entry point
│   ├── appsscript.json    # GAS manifest (auto-copied)
│   └── index.html         # Optional: for web apps
├── vite.config.ts
└── package.json

Requirements

  • Vite 5+
  • Node.js 20+

License

MIT