ESBuild plugin and CLI for bundling modern TS/JS code into Google App Script
npm install gas-buildAn ESBuild plugin and simplified CLI for bundling of Google App Script projects from
a modern TypeScript / JavaScript codebase.
``bash`
npm install -D gas-build esbuildesbuild
This installs both the plugin and the CLI. Note that is declared as a peer
dependency and must be installed separately.
To build your project, call the gas-build command with the entry point file and the output file:
`bash`
gas-build src/index.ts --outfile dist/bundle.jspackage.json
Note that you might have to wrap the command in a script so that the gas-build
is properly recognized:
`json`
{
"scripts": {
"build": "gas-build src/index.ts --outfile dist/bundle.js"
}
}
#### Watch mode
The CLI also supports simple watch mode. Enable it by passing the --watch flag:
`bash`
gas-build src/index.ts --outfile dist/bundle.js --watch
API, and include the gasBuildPlugin.`javascript
// filename: build.mjs
import { build } from 'esbuild'
import { gasBuildPlugin } from 'gas-build'await build({
entryPoints: ['src/index.ts'],
bundle: true,
// make sure there is a single output file
// for the pluging to process
outfile: 'dist/bundle.js',
platform: 'node',
target: 'es2020',
format: 'esm',
plugins: [gasBuildPlugin()],
})
`Run the build script using
node:`bash
node build.mjs
``