Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)8.1k · #12581

api-bundle-size-limit

Skill này làm gì

Skill này giúp AI của bạn thay đổi giới hạn kích thước của bản build API Webiny. Dành cho lập trình viên có bản build API thất bại vì bundle lớn hơn giới hạn mặc định.

Khi nào nên dùng

  • ✓Khi bản build API Webiny của bạn thất bại với lỗi giới hạn kích thước asset.
  • ✓Khi bundle API của bạn lớn hơn giới hạn mặc định 4,5 MB.
  • ✓Khi bạn muốn áp dụng giới hạn kích thước chặt hơn cho bundle API.

Liên kết skill

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api-bundle-size-limit/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api-bundle-size-limit/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bản build Webiny của tôi thất bại với lỗi giới hạn kích thước asset. Hãy tăng giới hạn bundle API lên 6 MB.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill chỉ cách thêm một thiết lập vào file cấu hình Webiny, với kích thước viết bằng byte. Nó cũng giải thích cách đọc thông báo lỗi build.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

API Bundle Size Limit

TL;DR

The Infra.Api.MaxBundleSize extension enforces a maximum size on the built API Lambda bundle. The default limit is 4.5 MB. If the bundle exceeds the limit the build fails with a clear error; add the extension to webiny.config.tsx to raise (or lower) it.

Default Behavior

By default Webiny enforces a 4.5 MB limit on the API Lambda bundle (handler.mjs). If the built output exceeds this, the build fails:

error   Build errors:
× asset size limit: The following asset(s) exceed the recommended size limit (4.5 MiB).
× entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (4.5 MiB).
error   build failed

Raising the Limit

Add Infra.Api.MaxBundleSize to webiny.config.tsx with size in bytes:

// webiny.config.tsx
import { Infra } from "webiny/extensions";

export const Extensions = () => (
  <>
    {/* Raise the API bundle size limit to 6 MB */}
    <Infra.Api.MaxBundleSize size={6 * 1024 * 1024} />
  </>
);

Common byte values:

MB Bytes expression Exact bytes
4.5 Math.round(4.5 * 1024 * 1024) 4718592 (default)
5 5 * 1024 * 1024 5242880
6 6 * 1024 * 1024 6291456
8 8 * 1024 * 1024 8388608
10 10 * 1024 * 1024 10485760

How It Works

The extension sets the WEBINY_INFRA_API_MAX_BUNDLE_SIZE environment variable (in bytes) which is read by the API bundler (@webiny/build-tools) at build time. The WEBINY_INFRA_ prefix ensures the variable is not automatically forwarded to the Lambda function's runtime environment.

Lowering the Limit

You can also enforce a stricter limit to catch bundle regressions early:

{
  /* Enforce a strict 3 MB limit */
}
<Infra.Api.MaxBundleSize size={3 * 1024 * 1024} />;

Quick Reference

Task Snippet
Raise to 6 MB <Infra.Api.MaxBundleSize size={6 * 1024 * 1024} />
Raise to 10 MB <Infra.Api.MaxBundleSize size={10 * 1024 * 1024} />
Restore default (4.5 MB) Remove the extension
Convert MB to bytes Math.round(N * 1024 * 1024)

Related Skills

  • infra-env-var -- setting arbitrary environment variables in the project context
  • api-lambda-function -- adding custom Lambda functions to the API
Câu hỏi thường gặp

Giới hạn mặc định là bao nhiêu?

Giới hạn mặc định cho Lambda bundle của API là 4,5 MB.

Thiết lập dùng đơn vị gì?

Nó dùng byte, nên 6 MB được viết là 6 nhân 1024 nhân 1024.

Tôi có thể làm giới hạn chặt hơn không?

Có. Skill nói bạn có thể đặt giới hạn thấp hơn để áp dụng kích thước chặt hơn.

Chi tiết

Mô tả gốc của tác giả

Covers how to configure the maximum allowed size of the Webiny API Lambda bundle using the Infra.Api.MaxBundleSize extension in webiny.config.tsx. Use when a project's API bundle exceeds the default 4.5 MB limit or when you want to enforce a stricter limit. Handles the extension syntax, byte calculations, and interpreting the build error message.

repo: webiny/webiny-js

Độ phổ biến

Sao GitHub
8.1k
Vị trí xếp hạng
#12581
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự