Skip to content

Optimizing for server environments #1181

@eltigerchino

Description

@eltigerchino

Describe the problem

When combined with @cloudflare/vite-plugin, most deps are prebundled before they are loaded by the workerd runtime during development. This means that the esbuild optimizer plugin should generate server code in these cases instead of always generating client code.

This is important to enable SvelteKit to work with the Cloudflare Vite plugin in development, which currently receives client Svelte code when performing SSR.

Describe the proposed solution

The Svelte compiler generates client/server code depending on the Vite environment when optimizing dependencies.

EDIT: sapphi mentioned it's possible to set a different esbuild plugin during the configureEnvironment hook

Alternatives considered

If we waited for Rolldown to officially replace esbuild, we wouldn't need to bother with tweaking the esbuild plugin. But I think that might still be a long time from now.

We could also probably workaround this by ensuring SvelteKit doesn't get optimized during development.

Importance

I cannot use vite-plugin-svelte without it

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy