esbuild-plugin-gas-generator
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

esbuild-plugin-gas-generator

npm version

This plugin allows you to execute functions exported within Google Apps Script (GAS) environment.

Installation

npm install --save-dev esbuild-plugin-gas-generator

Usage

How to use the plugin in your build script:

build.js

const esbuild = require("esbuild");
const GasPlugin = require("esbuild-plugin-gas-generator");

esbuild
  .build({
    entryPoints: ["src/index.js"],
    // Must be set to true
    bundle: true,
    // Must be set to 'iife'
    format: "iife",

    // Automatically set true
    metafile: true,

    // Must be followed
    outfile: "dist/bundle.js",
    plugins: [GasPlugin({
      appsscript: "appsscript.json",
      // Or you can specify the options directly
      appsscript: {
        timeZone: "Asia/Tokyo",
        dependencies: {},
        exceptionLogging: "STACKDRIVER",
        runtimeVersion: "V8"
      }
    })],
  })
  .catch((e) => {
    console.error(e);
    process.exit(1);
  });

src/index.js

export function hello() {
  console.log("Hello, World!");
}

Options

You can pass an object with options to the plugin:

  • appsscript (string | object): The path to the appsscript.json file or an object with the options directly.
  • excludePlugins (string[]): This plugin performs the build process twice. If other plugins also perform the build process twice, the build will not complete, so please exclude them.
const esbuild = require("esbuild");
const GasPlugin = require("esbuild-plugin-gas-generator");

esbuild
  .build({
    entryPoints: ["src/index.js", "src/main.js"],
    bundle: true,
    format: "esm",
    outdir: "dist",
    plugins: [
      GasPlugin({
        excludePlugins: ["esbuild-plugin-examples"]
        appsscript: "appsscript.json",
      }),
    ],
  })
  .catch((e) => {
    console.error(e);
    process.exit(1);
  });

License

MIT

Package Sidebar

Install

npm i esbuild-plugin-gas-generator

Weekly Downloads

82

Version

2.0.2

License

MIT

Unpacked Size

40.9 kB

Total Files

13

Last publish

Collaborators

  • miyaji255