Skip to content
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

Feature: Allow SSR build to output ES #2152

Closed
rschristian opened this issue Feb 21, 2021 · 3 comments · Fixed by #6812 or #8348
Closed

Feature: Allow SSR build to output ES #2152

rschristian opened this issue Feb 21, 2021 · 3 comments · Fixed by #6812 or #8348

Comments

@rschristian
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I'd like to use the SSR output as part of a larger application which has "type": "module" set. However, SSR is hard-coded to only output CJS.

format: ssr ? 'cjs' : 'es',

Describe the solution you'd like

I'd like to be able to customize/change this, best solution would probably be via Vite detecting the module type.

Describe alternatives you've considered

Could add another flag, but I think that's a bit much and I'd hesitate to add yet another.

Additional context

I'll probably write up a PR for this myself, but wanted to get this out there first.

@rschristian
Copy link
Contributor Author

rschristian commented Feb 21, 2021

Looking into this more, it seems Vite is built on assumptions that modern output = browser. Might be a bigger change than I imagined. <-- Actually got changed from something unrelated so that's no longer an issue

@awacode21
Copy link

This is exactly my problem. I was so long searching for what I am doing wrong, it drove me totally crazy!!!!! But yeah, when it's hard coded...... we really should have the option to output ES.

As this issue is 1 year old, and there is still nothing merged... do you know any work around??
the server.js expects entry-server.js to be ES module, but in fact it got outputted as CJS. How can i workaround it to not be completely stopped with my work until this gets closed.

@awacode21
Copy link

Workaround with build.rollupOptions.output.format is possible.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.