serverless-esbuild
serverless-esbuild copied to clipboard
Set output filename/extension
Is your feature request related to a problem? Please describe.
Getting the following error when trying to run a build in an ESM project:
✖ Unhandled exception in handler 'graphql'.
✖ ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/simon/Development/west-app/web/.esbuild/.build/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
Describe the solution you'd like
It seems this is fixed by giving the output file a .cjs extension. It would be great to specify the extension/filename as an option.
Looks like this is possible with the following:
custom:
esbuild:
outExtension:
".js": .cjs
But perhaps it could be documented?
@archy-bold this settings duplicate output with a .js
and .mjs
file. It's not possible to only export with .mjs
extension ?