Skip to content

fix(api-server): lambdaLoader: improve handler import logic... #12064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

richard-stafflink
Copy link
Contributor

For ESModule and CommonJS compatibility.
When using a bundler like Rollup, the handler function is exported as default.

This change defaults to a named export, but has a fallback check for a named export if there is a default export.

@richard-stafflink richard-stafflink force-pushed the api-server-lambdaLoader-import-fallbacks branch from 3a6a238 to 50980b7 Compare July 11, 2025 01:49
@richard-stafflink
Copy link
Contributor Author

Related PR (lambdaLoader: add discoverfunctionsGlob option): #12063

For ESModule and CommonJS compatibility.
When using a bundler like Rollup, the handler function is exported as default.
@richard-stafflink richard-stafflink force-pushed the api-server-lambdaLoader-import-fallbacks branch from 50980b7 to 24f809c Compare July 11, 2025 03:22
Tobbe added a commit to cedarjs/cedar that referenced this pull request Jul 11, 2025
For ESModule and CommonJS compatibility.
When using a bundler like Rollup, the handler function is exported as
`default`.

This change defaults to a named `handler` export, just like before. But
if an export like that can't be found it'll now also look for a
`default` export with a `handler` property on it.

All credit for this one goes to @richard-stafflink who created the
original PR over at redwoodjs/graphql#12064

---------

Co-authored-by: Richard J <[email protected]>
Tobbe added a commit to cedarjs/cedar that referenced this pull request Jul 11, 2025
For ESModule and CommonJS compatibility.
When using a bundler like Rollup, the handler function is exported as
`default`.

This change defaults to a named `handler` export, just like before. But
if an export like that can't be found it'll now also look for a
`default` export with a `handler` property on it.

All credit for this one goes to @richard-stafflink who created the
original PR over at redwoodjs/graphql#12064

---------

Co-authored-by: Richard J <[email protected]>
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