`experimental.async` does not apply to dependency code
Open
Nobody has claimed this yet.
vite
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
When using async components, the dev server fails to start with the error shown below, even though experimental.async: true is set.
Workaround: add optimizeDeps.exclude: ['dependency-with-async-component'] to vite.config.
Reproduction
Logs
deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`
https://svelte.dev/e/experimental_async [plugin vite-plugin-svelte:optimize-module]
node_modules/@sjsf/sveltekit/dist/rf/client/client.svelte.js:75:34:
75 │ const initialValue = $derived(await getInitialValue());
╵ ^
The plugin "vite-plugin-svelte:optimize-module" was triggered by this import
node_modules/@sjsf/sveltekit/dist/rf/client/index.js:1:14:
1 │ export * from './client.svelte.js';
╵ ~~~~~~~~~~~~~~~~~~~~
at failureErrorWithLog (/home/projects/p6pycmm1/node_modules/esbuild/lib/main.js:1457:15)
at eval (/home/projects/p6pycmm1/node_modules/esbuild/lib/main.js:916:25)
at eval (/home/projects/p6pycmm1/node_modules/esbuild/lib/main.js:1335:9) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
System Info
System:
OS: Linux 5.0 undefined
CPU: (7) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
svelte: ^5.41.0 => 5.41.1
Severity
annoyance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction and the vite.config workaround, then trace the dependency through the vite-plugin-svelte:optimize-module path shown in the logs. Confirm how experimental.async is handled for optimized dependency code and verify that the reproduction starts without excluding the dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100