Rob N
03/24/2022, 1:30 AMawait
yet? Getting this error and I cant figure out how to resolve it even though node14 in lambda supports it.
[ERROR] Top-level await is not available in the configured target environment ("node14")
Example usecase is the graphql demo but building federation into apollo :
const federatedSchema = await buildFederatedSchema({
typeDefs: gql(printSchema(schema)),
resolvers: createResolversMap(schema) as any,
});
https://github.com/serverless-stack/serverless-stack/tree/master/examples/graphql-apolloMatt Morgan
03/24/2022, 1:33 AMformat: OutputFormat.ESM
and target: esnext
, among a few other gotchas.Matt Morgan
03/24/2022, 1:33 AMRob N
03/24/2022, 1:35 AMapp.setDefaultFunctionProps({
bundle: {
format: "esm",
},
});
seems to have workedMatt Morgan
03/24/2022, 1:35 AMMatt Morgan
03/24/2022, 1:35 AMRob N
03/24/2022, 1:35 AMMatt Morgan
03/24/2022, 1:35 AMthdxr
03/24/2022, 1:46 AMthdxr
03/24/2022, 1:46 AMMatt Morgan
03/24/2022, 1:47 AMMatt Morgan
03/24/2022, 1:48 AMthdxr
03/24/2022, 1:51 AMthdxr
03/24/2022, 1:51 AMMatt Morgan
03/24/2022, 1:54 AMRob N
03/24/2022, 2:19 AM"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"ReferenceError: __dirname is not defined",
which is coming from .build/run.js
any ideas what would cause that?thdxr
03/24/2022, 2:19 AMRob N
03/24/2022, 2:19 AM__dirname
doesnt exist when its esm
i get that but i dont actually have anything in my own code its just in the build outputRob N
03/24/2022, 2:20 AM// Check first and throw an error
if (!fs.existsSync(path.join(__dirname, "lib", "index.js"))) {
console.error(
`\nCannot find app handler. There was a problem transpiling the source.\n`
);
process.exit(1);
}
thdxr
03/24/2022, 2:23 AMRob N
03/24/2022, 2:23 AMRob N
03/24/2022, 2:23 AMthdxr
03/24/2022, 2:24 AMRob N
03/24/2022, 2:25 AMRob N
03/25/2022, 5:13 PMthdxr
03/25/2022, 5:19 PMthdxr
03/25/2022, 5:20 PMRob N
03/26/2022, 12:13 AM"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"ReferenceError: __dirname is not defined",
Rob N
03/26/2022, 12:14 AMthdxr
03/26/2022, 12:19 AM__dirname
which isn't allowed in esmRob N
03/26/2022, 12:28 AMRob N
03/26/2022, 12:29 AM