fastify / aws-lambda-fastify

Insipired by aws-serverless-express to work with Fastify with inject functionality.
MIT License
498 stars 32 forks source link

Provide the package as an ESModule #189

Closed HaaLeo closed 8 months ago

HaaLeo commented 8 months ago

Prerequisites

🚀 Feature Proposal

Currently the package cannot be used within an ESModule. When one tries to do so you get an error like

ReferenceError: require is not defined

Unfortunately the approaches mentioned in #89 do not work for me since I have concurrent initialization.

I am bundling my lambda function with webpack.

Motivation

With the package as an esmodule we can take advantage of top level awaits to further reduce cold start times.

Example

No response

HaaLeo commented 8 months ago

I think I might have missconfigured webpack node-externals. Adding the following config seems to remediate the error message:

    externals: [nodeExternals({ importType: 'module' })],