-
-
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
Prerender in subprocess #5306
Comments
Adding a new hook just for this purpose would be unfortunate, I think — especially since (as far as the user is concerned) the connection between prerendering and Instead, if we want to avoid exiting the main process, we should probably just do the prerendering in a child process that we can safely kill once prerendering is complete. |
A proper exit can't be guaranteed in all environments, especially serverless ones. |
This issue is just referring to things that would happen during prerendering right, and not at runtime? I would certainly hope that we can rely on all the Node stuff we want while the app is being built, regardless of which platform it is being deployed to. |
Ack, my bad. |
how about just adding a global IIRC I sent a PR for it a few months ago when trying to include pwa plugin in SvelteKit using the rollup interplugin communication api. |
Maybe completely wrong my questions here but, that this means that is not possible to run a plugin after the Based on what I tried I cannot use Meaning that based on this async closeBundle() {
if (svelte_config.kit.adapter) {
const { adapt } = await import('./build/adapt/index.js');
await adapt(svelte_config, build_data, prerendered, { log });
} else {
console.log(colors.bold().yellow('\nNo adapter specified'));
// prettier-ignore
console.log(
`See ${colors.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
);
}
if (is_build && svelte_config.kit.prerender.enabled) {
// this is necessary to close any open db connections, etc.
// TODO: prerender in a subprocess so we can exit in isolation
// https://github.com/sveltejs/kit/issues/5306
process.exit(0);
}
}, The only way to run some transformation on those files is to write a custom adapter right? |
@matiasfha the prerendered output files get generated in If |
@benmccann I like the idea behind Astro and iles, where you have a lot of hooks, this way ppl can Just add their hooks in the plugin. |
@benmccann the writeBundle hook can't read the prerendered output files in a reliable way. Looks like at the point the plugin calls this hook the previous plugin (the sveltekit one) is not yet done with it. |
I feel like adding SvelteKit hooks is not the ideal solution for this and we should instead use Vite hooks. That would allow Vite plugins to be used across projects in the Vite ecosystem and not just with SvelteKit
It looks like that's because they're called in parallel: https://rollupjs.org/guide/en/#output-generation-hooks So yeah, that introduces a bit of a conundrum. By default, if you do it in I guess this is why |
@benmccann thanks for the answer. |
@benmccann the plugin (there are 3) that generates the build has
|
fyi, it looks like closeBundle is also called when Details: |
Hmm. I'm not sure why |
@dominikg the build plugin has |
@userquin kit plugin does not set apply: kit/packages/kit/src/vite/index.js Line 132 in 578a288
|
@dominikg uhmmm, the result is the same, confirmed with |
yes, already added a PR to improve the kit plugin. Might be nice to split it into separate dev/build/common plugins to avoid conditionals inside the hooks 🤔 but thats out of scope here. I wanted to mention it as you all were discussing behavior of closeBundle and it caught me by surprise today. |
The prerendered process is in fact awaited here https://github.com/sveltejs/kit/blob/master/packages/kit/src/vite/index.js#L303 but even with that a new plugin that hooks into using
I'm testing with this little snippet
This can find the folders This is running against a new sveltekit project from scratch with the simple todo example. Also based on the rollup documentation
If I understood that correctly, after a plugin calls |
This Vite folks confirmed that |
Describe the problem
SvelteKit
exit
s:kit/packages/kit/src/vite/index.js
Line 312 in cfd38d4
This means you can't have another plugin after the SvelteKit plugin
Describe the proposed solution
Add a new
close
hookHave
prerender
callserver.close()
Alternatives considered
No response
Importance
Prevents https://github.com/userquin/pwa-sveltekit-vite from working
Additional Information
No response
The text was updated successfully, but these errors were encountered: