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

Custom email template fails to compile #152

Open
mmmewk opened this issue Feb 29, 2024 · 1 comment
Open

Custom email template fails to compile #152

mmmewk opened this issue Feb 29, 2024 · 1 comment

Comments

@mmmewk
Copy link

mmmewk commented Feb 29, 2024

I followed the documentation here: https://github.com/aws-samples/amazon-cognito-passwordless-auth/blob/main/CUSTOMIZE-AUTH.md to setup custom email templates and ran into an error

SyntaxError: Cannot use import statement outside a module.

This was fixed by adding:

import * as lambdaNodeJs from "aws-cdk-lib/aws-lambda-nodejs";

createAuthChallenge: {
  entry: "functions/src/passwordless/createAuthChallenge.ts",
  bundling: {
    format: lambdaNodeJs.OutputFormat.ESM,
    banner: "import{createRequire}from 'module';const require=createRequire(import.meta.url);",
  },
},

Looks like it needs ESM to use the import syntax.

@ottokruse
Copy link
Contributor

You're right, we do set it to ESM in the lib, but if you override the bundling property, you should add it again as you did.

Thanks for reporting. You're probably not the first one to run into this!

Want to send a PR to add it to the code example in the docs?

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

No branches or pull requests

2 participants