-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Does serverless-esbuild support ESM/ES Modules? #483
Comments
Looking at this a bit closer, the issue seems to be resolved if I remove |
I think I had some trouble with this too. My
And I end up with a I also had to add a banner like evanw/esbuild#1921 (comment) , but that may have been to deal with a not-fully-ESM module I was using. |
@timkingman how did you implemented edit: nvm, found it: custom:
esbuild:
format: esm
outputFileExtension: .mjs
banner:
js: import { createRequire } from 'module';const require = (await import('node:module')).createRequire(import.meta.url);const __filename = (await import('node:url')).fileURLToPath(import.meta.url);const __dirname = (await import('node:path')).dirname(__filename); |
My code consists of ES Modules, and I use
"type": "module"
inpackage.json
to make that clear. I do have a few config files (jest, eslint, and prettier) and a script file that are.cjs
extensions. They shouldn't execute when a request is sent to my endpoint, however. Everything works until I tried addingserverless-esbuild
to my project, at which point I get the below error (when I send a request to the endpoint running offline). Am I doing something wrong?Error
serverless.yaml
package.json
src/routes/get/handler.js
The text was updated successfully, but these errors were encountered: