Skip to content

fix: bundle generated warmer handler to avoid missing @smithy runtime dependency#364

Open
caaarlxs wants to merge 6 commits intojuanjoDiaz:mainfrom
caaarlxs:fix/bundle-warmer-handler
Open

fix: bundle generated warmer handler to avoid missing @smithy runtime dependency#364
caaarlxs wants to merge 6 commits intojuanjoDiaz:mainfrom
caaarlxs:fix/bundle-warmer-handler

Conversation

@caaarlxs
Copy link
Copy Markdown

Context: When using Serverless Framework v4 (or packaging with warmup patterns that only include .warmup/**), the generated warmup handler imports @smithy/node-http-handler (and @aws-sdk/client-lambda) but the warmer artifact does not include node_modules, causing runtime ERR_MODULE_NOT_FOUND.

Root cause: The plugin’s default packaging pattern excludes node_modules, but the generated handler depends on external modules.

Change: After writing .warmup//index.mjs, bundle it with esbuild into a self-contained ESM file and replace the original index.mjs.

Result: The warmer artifact remains minimal and works without requiring users to manually include node_modules patterns; fixes missing module errors for @smithy/*.

Verification:

  • serverless package produces a warmup zip containing only .warmup/**/index.mjs
  • Deployed warmer runs successfully (no ERR_MODULE_NOT_FOUND)

@caaarlxs
Copy link
Copy Markdown
Author

This PR should also address issue #365 (ERR_MODULE_NOT_FOUND with @smithy/node-http-handler).

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.

1 participant