Open ffMathy opened 1 year ago
If I manually go in and rename the app.mjs.js
file to app.mjs
and then change the template.yml
to also point to app.handler
instead of app.mjs.handler
, it works just fine.
So I suppose this should be an easy fix maybe?
What do you think?
As a workaround, I can do this:
filename: (chunkData) => awsSamPlugin.filename(chunkData).replace(".js", ".mjs")
In the config.
See https://aws.amazon.com/blogs/compute/using-node-js-es-modules-and-top-level-await-in-aws-lambda/
Here is my template file:
When running the plugin, the final template file generated is this:
Note that
app.mjs.handler
is wrong. It should be justapp.handler
.In my
webpack.config.js
, I have:output.library.type
set to"module"
.output.library.chunkFormat
set to"module"
.experiments.outputModule
set totrue
.In my
package.json
,type
is set to"module"
.With this,
.mjs
files are generated instead of.js
files. But because the file generated is calledapp.mjs.js
instead ofapp.mjs
, Lambda doesn't load it as an ES Module.