Skip to content

fix: resolve #12960 — Allow configuring "build.packages: external" on a per-function level#13482

Open
tang-vu wants to merge 1 commit intoserverless:mainfrom
tang-vu:contribai/feat/add-build-configuration-to-function-sche
Open

fix: resolve #12960 — Allow configuring "build.packages: external" on a per-function level#13482
tang-vu wants to merge 1 commit intoserverless:mainfrom
tang-vu:contribai/feat/add-build-configuration-to-function-sche

Conversation

@tang-vu
Copy link
Copy Markdown

@tang-vu tang-vu commented Apr 4, 2026

Summary

fix: resolve #12960 — Allow configuring "build.packages: external" on a per-function level

Problem

Severity: Medium | File: lib/configSchema.js

Updates the AWS Lambda function schema to allow a build property, which currently supports esbuild settings such as packages. This enables per-function configuration of the bundler.

Solution

In the definitions.awsLambdaFunctionProperties.properties section, add the following:

Changes

  • lib/configSchema.js (new)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Generated by ContribAI v5.7.1

Summary by CodeRabbit

  • New Features
    • Added build configuration schema support, enabling users to configure esbuild package handling options.

…ternal" on a per-function level

Fixes serverless#12960

Signed-off-by: Tang Vu <145498528+tang-vu@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@Mmarzex
Copy link
Copy Markdown
Contributor

Mmarzex commented Apr 4, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

Added a new build configuration schema to lib/configSchema.js that defines an esbuild object with a packages property restricted to the external enum value. This enables per-function build configuration without allowing additional unspecified properties.

Changes

Cohort / File(s) Summary
Build Configuration Schema
lib/configSchema.js
Added new build schema definition with esbuild object containing packages field (enum: external), both with additionalProperties: false; missing trailing newline.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A schema block hops into place,
Where esbuild finds its rightful space,
With packages marked "external" true,
Per-function builds now shine on through!
No bundling woes shall slow us down,
Configuration wears the crown! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding per-function configuration support for build.packages setting to resolve issue #12960.
Linked Issues check ✅ Passed The code changes add the required build configuration schema to enable per-function esbuild packages configuration as requested in issue #12960.
Out of Scope Changes check ✅ Passed Changes are narrowly scoped to adding build schema configuration in lib/configSchema.js, directly addressing the requirement to support per-function build.packages setting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/configSchema.js`:
- Line 12: The schema currently sets additionalProperties: false on the build
object which blocks plugins from extending build config via defineBuildProperty;
remove the additionalProperties: false constraint from the build object in
lib/configSchema.js (or replace it with an anyOf/oneOf variant that permits
plugin-registered keys) so that defineBuildProperty (see config-schema-handler's
defineBuildProperty usage) can add plugin-specific properties like "esbuild"
without failing validation.
- Line 7: Update the config schema so the packages enum allows both esbuild
values instead of only 'external': locate the configSchema object where the
packages property is defined (the "packages" key in lib/configSchema.js) and
change its enum to include 'bundle' as well (e.g., enum: ['external','bundle'])
so users can explicitly choose bundling behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9866c9c0-7727-4c8a-a69c-a1974aab3119

📥 Commits

Reviewing files that changed from the base of the PR and between 15071ae and 8c48e13.

📒 Files selected for processing (1)
  • lib/configSchema.js

esbuild: {
type: 'object',
properties: {
packages: { type: 'string', enum: ['external'] },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

What are the valid values for esbuild's "packages" configuration option?

💡 Result:

The valid values for esbuild's "packages" configuration option are 'bundle' and 'external'.

Citations:


Expand packages enum to include valid esbuild configuration values.

The packages property is restricted to ['external'], but esbuild's packages option supports both 'bundle' and 'external'. This prevents users from explicitly configuring bundling behavior. Update the enum to include all valid values:

Fix
-                    packages: { type: 'string', enum: ['external'] },
+                    packages: { type: 'string', enum: ['bundle', 'external'] },
🧰 Tools
🪛 Biome (2.4.10)

[error] 7-7: Expected an expression but instead found 'enum'.

(parse)


[error] 7-7: Expected a statement but instead found ','.

(parse)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/configSchema.js` at line 7, Update the config schema so the packages enum
allows both esbuild values instead of only 'external': locate the configSchema
object where the packages property is defined (the "packages" key in
lib/configSchema.js) and change its enum to include 'bundle' as well (e.g.,
enum: ['external','bundle']) so users can explicitly choose bundling behavior.

additionalProperties: false,
},
},
additionalProperties: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: additionalProperties: false breaks plugin extensibility.

Setting additionalProperties: false on the build object will prevent plugins from adding their own build configurations via the defineBuildProperty method (shown in context snippet 1 from lib/classes/config-schema-handler/index.js:168-179). This breaks the plugin system's ability to extend build configuration.

For example, the esbuild plugin itself uses defineBuildProperty('esbuild', { ... }) to register its schema. If additionalProperties: false is enforced before plugin registration, this will fail validation.

Remove additionalProperties: false from line 12, or restructure the schema to use anyOf with plugin-extensible object variants.

🔓 Proposed fix: Remove the restrictive constraint
-              additionalProperties: false,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
additionalProperties: false,
🧰 Tools
🪛 Biome (2.4.10)

[error] 11-12: Expected a statement but instead found ',
additionalProperties: false,'.

(parse)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/configSchema.js` at line 12, The schema currently sets
additionalProperties: false on the build object which blocks plugins from
extending build config via defineBuildProperty; remove the additionalProperties:
false constraint from the build object in lib/configSchema.js (or replace it
with an anyOf/oneOf variant that permits plugin-registered keys) so that
defineBuildProperty (see config-schema-handler's defineBuildProperty usage) can
add plugin-specific properties like "esbuild" without failing validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring "build.packages: external" on a per-function level

2 participants