-
-
Notifications
You must be signed in to change notification settings - Fork 151
feat: add support for .mjs file output #333
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
feat: add support for .mjs file output #333
Conversation
e11ec2b
to
0080a7b
Compare
PR changed to be more configurable |
Hi @codingnuclei , thank you for the careful PR. I think it's a necessary addition. |
@floydspace This might be me being silly - but I am not seeing any comments? |
@codingnuclei oh I was not aware that comments are not visible unless a review is submitted, so it was silly from my side |
0080a7b
to
b799b34
Compare
@floydspace updated with your comments resolved :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codingnuclei thank you, approved.
🎉 This PR is included in version 1.32.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hey.
This PR adds outputting
.mjs
files if the build optionplatform=neutral
.Currently we can use
platform=neutral
to output the bundle as esm. The bundle extension however remains.js
. This is fine when it is accompanied by apackage.json
which has"type": "module"
set.However, the `package.json' is explicitly not included in the final zip.
https://github.com/floydspace/serverless-esbuild/blob/master/src/pack.ts#L38
This means that lambdas run the code as CommonJs.
Changing the file type seems a more explicit option (rather than package the
package.json
)Considerations:
-platform=neutral
now outputs.mjs
filesNotes on testing
buildOptions
in tests. I have therefore casted when added to the overrides. Keeping the variable typed should ensure the type safety.First PR to serverless-esbuild so let me know if you require anything else.
Partially closes #315 (
package.json
is no longer required)Update
Have updated so that
.js
is the default extension thereby making this a none breaking change.If you wish to change the extension you can now use the new
outputFileExtension
which has some validation to keep the user right.