Skip to content
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

lambda-js: Add note about esbuild module exports #594

Merged
merged 4 commits into from Oct 17, 2023

Conversation

indrora
Copy link
Contributor

@indrora indrora commented Jul 20, 2023

This change adds a short blurb about requirements for users who are using esbuild.

As discussed in aws-observability/aws-otel-lambda#99 there is a quirk of esbuild that causes exported functions using the export keyword to be marked immutable in the transpiled JS. As a result, you must use module.exports instead, which is passed along by the esbuild transpilation process unscathed.

This change adds a short blurb about requirements for users who are using esbuild.

As discussed in aws-observability/aws-otel-lambda#99 there is a quirk of esbuild that causes exported functions using the `export` keyword to be marked immutable in the transpiled JS. As a result, you must use `module.exports` instead, which is passed along by the esbuild transpilation process unscathed.
@senock-dag
Copy link

Hi @indrora - good idea adding a note to the readme!

I'm running into the same issue, but the solution I see doesn't work with my implementation and I'm trying to troubleshoot what's going on.

If I update my exports to use module.exports, the other files that import my handler receives the following error:

Module '"../../../../src/authorizer"' declares 'authorizer' locally, but it is not exported

Do you have any advice on how I can use module.exports within my TS files?

@vasireddy99
Copy link
Contributor

Hi @indrora - good idea adding a note to the readme!

I'm running into the same issue, but the solution I see doesn't work with my implementation and I'm trying to troubleshoot what's going on.

If I update my exports to use module.exports, the other files that import my handler receives the following error:

Module '"../../../../src/authorizer"' declares 'authorizer' locally, but it is not exported

Do you have any advice on how I can use module.exports within my TS files?

I do not have the total context on the suggestion but based on the context but you can try using like - module.exports = authorizer;

@vasireddy99 vasireddy99 merged commit f90a1b1 into aws-otel:main Oct 17, 2023
3 checks passed
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.

None yet

3 participants