Skip to content

svelte-kit sync generates types twice #17394

Description

@Mokto

Describe the bug

Since 3.0, svelte-kit sync resolves the Vite config with vite.resolveConfig(..., 'build') (load_vite_config in src/cli.js). During that call, the config hook of the build plugin (src/exports/vite/build/index.js) already runs a full sync:

manifest_data = create_manifest_data(kit, root);
set_manifest_data(manifest_data);
sync.all(kit, root, manifest_data);

sync.all includes write_all_types. After load_vite_config returns, the CLI calls sync.all_types(sveltekit_config, vite_config.root). That builds the manifest and writes all types a second time.

On an app with ~120 route modules, a CPU profile of svelte-kit sync shows ~160–220ms in the plugin's sync and another ~115ms in the CLI's all_types. The whole command takes ~0.8s, so the repeat is about 15% of it. The code is the same on main.

The CLI could skip all_types when the plugin has already synced, or the plugin could skip its sync when the CLI invokes it.

Reproduction

  1. In any SvelteKit 3 app with a few routes, run:
    node --cpu-prof --cpu-prof-dir=prof node_modules/@sveltejs/kit/svelte-kit.js sync
  2. Open the profile, for example in Chrome DevTools. create_manifest_data and write_all_types each run twice: once under exports/vite/build/index.js (config handler, via sync.all) and once under cli.js (via sync.all_types).

Logs

No response

System Info

System: macOS 26 (Darwin 25.6.0), Apple Silicon
Node: 24.21.0
@sveltejs/kit: 3.0.0 (the code paths are unchanged on main / 3.0.1)
vite: 8.3.2
svelte: 5.57.2

Severity

annoyance

Additional Information

We run svelte-kit sync before every type check (svelte-kit sync && svelte-check), so the duplicate cost adds up during local development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions