Registry / devops / esbuild-plugin-serverless

esbuild-plugin-serverless

JSON →
library1.0.2jsnpmunverified

An esbuild plugin that provides hot-module-replacement-like behavior for Node.js Cloud Functions on Yandex Cloud by rebuilding and deploying on save without writing compiled files to disk. Version 1.0.2 requires peer dependencies @yandex-cloud/nodejs-sdk ^2.7.7 and esbuild ^0.25.5. Designed specifically for Yandex Cloud serverless functions, it handles runtime configuration, environment variable injection via getFromEnv, and automatic re-deployment on file changes.

npm install esbuild-plugin-serverless
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-SER
E
esbuild-plugin-serverless
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

esbuildServerlessPlugin
import esbuildServerlessPlugin from 'esbuild-plugin-serverless'
const { esbuildServerlessPlugin } = require('esbuild-plugin-serverless')
Default export is a function. Avoid destructuring require.
Entrypoints
import { Entrypoints } from 'esbuild-plugin-serverless'
Named export for the entrypoints configuration type. Also importable from 'esbuild-plugin-serverless/entrypoint'.
getFromEnv
import { getFromEnv } from 'esbuild-plugin-serverless'
Helper to read environment variables with type safety.
EntrypointConfig
import { EntrypointConfig } from 'esbuild-plugin-serverless'
Type for defining a single entrypoint configuration.

Sets up esbuild watch mode with the serverless plugin to rebuild and deploy on file changes to Yandex Cloud.

import { Entrypoints, getFromEnv, esbuildServerlessPlugin } from 'esbuild-plugin-serverless' import { context } from 'esbuild' const common = { runtime: 'nodejs16', tag: ['latest'], resources: { $type: 'yandex.cloud.serverless.functions.v1.Resources', memory: 128 * 1024 * 1024 }, executionTimeout: { $type: 'google.protobuf.Duration', seconds: 5, nanos: 0 } } const entrypoints: Entrypoints = { index: () => ({ ...common, functionId: getFromEnv('CLOUD_FUNCTION_ID'), entrypoint: 'index.handler' }) } const build = async () => { process.env.NODE_ENV = 'PRODUCTION' const ctx = await context({ entryPoints: ['./src/index.ts'], bundle: true, platform: 'node', target: 'node16', external: ['@yandex-cloud/nodejs-sdk'], outdir: 'build', write: false, plugins: [esbuildServerlessPlugin(entrypoints, { '@yandex-cloud/nodejs-sdk': '*' })] }) await ctx.watch() } build()
Debug
Known issues
gotchaRequires Yandex Cloud credentials: YC_ACCESS_KEY_ID, YC_SERVICE_ACCOUNT_ID, YC_PRIVATE_KEY must be set in environment, or running on a VM with a service account.
fix
Set the three environment variables from a Yandex Cloud service account authorized key, or deploy on a VM with a service account attached.
affects: >=0.0.0
breakingVersion 1.0.0 changed the plugin's export to default, removing the named export. Previous versions used { esbuildServerlessPlugin }.
fix
Update import to `import esbuildServerlessPlugin from 'esbuild-plugin-serverless'`.
affects: <1.0.0
deprecatedThe runtime 'nodejs16' is used in examples; Yandex Cloud may deprecate older runtimes.
fix
Check Yandex Cloud documentation for current supported runtimes (e.g., nodejs18).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-serverless/entrypoint'
Wrong import path; the named export Entrypoints is exported from the main module.
fix
Use `import { Entrypoints } from 'esbuild-plugin-serverless'` instead of `from 'esbuild-plugin-serverless/entrypoint'`.
TypeError: esbuildServerlessPlugin is not a function
Using CommonJS require with destructuring instead of importing the default export.
fix
Use `import esbuildServerlessPlugin from 'esbuild-plugin-serverless'`.
Error: getFromEnv is not defined
Attempting to use `getFromEnv` without importing it.
fix
Add `import { getFromEnv } from 'esbuild-plugin-serverless'` at the top of the file.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
@yandex-cloud/nodejs-sdkrequiredUsed for Yandex Cloud SDK operations
esbuildrequiredRequired as the bundler and for creating build contexts
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-serverless — npm install esbuild-plugin-serverless · libregistry