-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Generate ESM functions for Netlify #6666
Conversation
|
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.
Thank you! Thank you! THANK YOU!
The generated function files use the .mjs extension
Is it necessary to use the .mjs
extension if a user has "type": "module"
in their package.json
? (which all SvelteKit users will have)
We're in the final stages of rolling out this functionality to all customers, but wanted to get the PR in front of you sooner rather than later to gather any feedback and improve the experience for SvelteKit users as soon as possible.
To clarify, would it be okay if we merge this PR and roll it out to our users now or do we need to wait for something on your side still?
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
For now, yes. We'll gradually roll out ESM support for
We need to update our CLI with this change, which we'll do today. I'll keep this thread updated and let you know once it's good to merge. |
Does this work properly if somebody has manually set their bundler to esbuild? |
Yes, esbuild will respect these settings. |
We've released CLI v11.7.1 with support for these changes. I still want to do a couple of end-to-end tests, but I'm not sure I'll be able to do that today. It's on the top of my list for Monday, though! |
This is all good to go from our side. Let me know if there's anything else that I need to do to get this merged and released. Thanks! 🙌🏻 |
Awesome!! Thank you so much! |
Netlify currently transpiles serverless functions with ESM syntax down to CJS, which is causing problems such as #6462.
We've started to address that in netlify/zip-it-and-ship-it#1198, which emits ESM files for functions with a
.mjs
extension. Because this is technically a breaking change, we're rolling it out gradually, but we've created a configuration property that allows frameworks like SvelteKit to opt-in to this behaviour straight away. This is done with a per-function configuration file introduced in netlify/zip-it-and-ship-it#1030.With that in place, this PR has the following changes:
.mjs
extensionWe're in the final stages of rolling out this functionality to all customers, but wanted to get the PR in front of you sooner rather than later to gather any feedback and improve the experience for SvelteKit users as soon as possible.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0