api-bundle-size-limit

Configures the maximum Webiny API Lambda bundle size via the Infra.Api.MaxBundleSize extension.

8.0k|673|Updated Jan 9, 2018
One-click install
npx skills add https://github.com/webiny/webiny-js --skill api-bundle-size-limit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-bundle-size-limit
Source: https://github.com/webiny/webiny-js/tree/main/skills/user-skills/api-bundle-size-limit
Command: npx skills add https://github.com/webiny/webiny-js --skill api-bundle-size-limit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Webiny enforces a default 4.5 MB limit on the built API Lambda bundle, and builds fail with an asset size limit error when the output exceeds it. This Skill explains how to raise or lower that limit so builds succeed or regressions are caught early.

Core Features & Use Cases

  • Raise the limit: Add the Infra.Api.MaxBundleSize extension in webiny.config.tsx with a size in bytes to allow larger API bundles.
  • Enforce stricter limits: Set a lower byte threshold to catch bundle size regressions during builds.
  • Byte conversion reference: Provides a lookup table converting megabytes to exact byte expressions.
  • Use Case: Your Webiny project build fails with "asset size limit: The following asset(s) exceed the recommended size limit (4.5 MiB)". Add <Infra.Api.MaxBundleSize size={6 * 1024 * 1024} /> to webiny.config.tsx to raise the limit to 6 MB and rebuild.

Quick Start

Add the Infra.Api.MaxBundleSize extension with a byte size to webiny.config.tsx to change the API bundle size limit.

Frequently Asked Questions about api-bundle-size-limit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix the Webiny API bundle size limit build error?

Add the Infra.Api.MaxBundleSize extension to webiny.config.tsx with a larger size in bytes, such as <Infra.Api.MaxBundleSize size={6 * 1024 * 1024} /> for 6 MB. The default limit is 4.5 MB, and exceeding it fails the build.

What is the default Webiny API Lambda bundle size limit?

The default limit is 4.5 MB (4718592 bytes) on the built handler.mjs bundle. If the output exceeds this, the build fails with an asset size limit error from the bundler.

How do I convert megabytes to bytes for MaxBundleSize?

Multiply the megabyte value by 1024 twice, for example 6 * 1024 * 1024 equals 6291456 bytes. For fractional values like 4.5 MB, use Math.round(4.5 * 1024 * 1024).

Can I enforce a smaller API bundle size limit in Webiny?

Yes, set Infra.Api.MaxBundleSize to a lower byte value, such as 3 * 1024 * 1024 for 3 MB. This makes builds fail earlier, helping catch bundle size regressions before they grow.

Does the MaxBundleSize variable get passed to the Lambda runtime?

No. The extension sets the WEBINY_INFRA_API_MAX_BUNDLE_SIZE environment variable, and the WEBINY_INFRA_ prefix prevents it from being forwarded to the Lambda function's runtime environment. It is only read at build time.