-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Create CJS build output, or expect adapters to bundle the ESM themselves? #503
Comments
Specifically for Vercel:
Node 10 EOL is April 30th, 2020, so at least that's one adapter where going full ESM will be possible. Not sure about the other serverless platforms or something more exotic like Cloudflare Workers. This was part of why I decided to go with the current "CJS entrypoint, ESM everything else" approach - it's practical, it works now instead of waiting on the platforms to update, and it's easy to rip out the CJS entrypoint once we can migrate it to full ESM. The current requirement to bundle all SSR dependencies for serverless functions is also a bit unfortunate, as it means the file is just one giant blob of JS that takes longer and longer to execute the more SSR dependencies you include, instead of importing the ones you need at runtime. That's also something dependent on the platforms to support, though. |
in an experiment to adapt to AWS lambdas I ended up building to CJS directly in the output directory. Not the cleanest solution. Probably allowing an adapter to have full access to the rollup settings used to build the app would clear all possible future cases. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
See also: #612 |
From #485 (comment):
tl;dr most lambda platforms seem to expect CJS, even though Node itself runs ESM natively. The best outcome would probably be if those adapters had access to a single CJS file with no external dependencies (since the platform's bundlers don't always work as you'd hope), though the possibility of native modules in the dep graph makes this a bit of a challenge. So exporting CJS from Vite alongside the ESM is probably the easiest solution, even if it's a bit wasteful.
We could eliminate the waste if the adapter was able to declare its requirements to
build
.The text was updated successfully, but these errors were encountered: