You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using AWS Lambda, there must be a function exported called "handler".
Normally, we can export the handler function without any issues.
However, with "TopLevelAwait" enabled, the bundled file does not work with AWS Lambda. This is because the "handler" function is exported as y = n ? Symbol.for("@reflect-metadata:registry") : void 0, which is not a regular function and therefore won't be recognized by AWS Lambda.
To be completely fair, ESModules natively support top-level await, which means we don't need to do extra work to build a separate implementation for it. Nonetheless, please help find a way to solve this issue.
When the line console.log(await bb()); is commented out, the handler function can be exported correctly in the build file, and it works properly on AWS Lambda.
However, when the line console.log(await bb()); is enabled, the handler function is built as y = n ? Symbol.for("@reflect-metadata:registry") : void 0, which is not a regular function and therefore won't be recognized by AWS Lambda.
Please run the npm build script to regenerate the file.
The text was updated successfully, but these errors were encountered:
System Info
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Memory: 1.97 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
npm: 10.8.1 - ~/.nvm/versions/node/v20.14.0/bin/npm
Browsers:
Chrome: 126.0.6478.127
Safari: 17.5
npmPackages:
@rspack/cli: 1.0.0-alpha.3 => 1.0.0-alpha.3
@rspack/core: 1.0.0-alpha.3 => 1.0.0-alpha.3
Details
When using AWS Lambda, there must be a function exported called "handler".
Normally, we can export the handler function without any issues.
However, with "TopLevelAwait" enabled, the bundled file does not work with AWS Lambda. This is because the "handler" function is exported as y = n ? Symbol.for("@reflect-metadata:registry") : void 0, which is not a regular function and therefore won't be recognized by AWS Lambda.
To be completely fair, ESModules natively support top-level await, which means we don't need to do extra work to build a separate implementation for it. Nonetheless, please help find a way to solve this issue.
Thanks,
CJ
Reproduce link
https://github.com/cjnoname/example-esm-lambda
Reproduce Steps
In the "lambda.ts" file:
When the line console.log(await bb()); is commented out, the handler function can be exported correctly in the build file, and it works properly on AWS Lambda.
However, when the line console.log(await bb()); is enabled, the handler function is built as y = n ? Symbol.for("@reflect-metadata:registry") : void 0, which is not a regular function and therefore won't be recognized by AWS Lambda.
Please run the npm build script to regenerate the file.
The text was updated successfully, but these errors were encountered: