Skip to content

support experimental.async option in compileModule #1174

Closed
@Rich-Harris

Description

@Rich-Harris

Describe the bug

This call here...

const compileResult = svelteCompiler.compileModule(code, {
dev: !this.environment.config.isProduction,
generate: ssr ? 'server' : 'client',
filename: moduleRequest.filename
});

...isn't passing experimental.async through, meaning that if someone has a $derived(await ...) in a .svelte.js or .svelte.ts module, it will blow up. (The option should only be added if it's been provided, of course, otherwise it'll fail validation)

Reproduction URL

https://github.com/sveltejs/svelte

Reproduction

Add the following to any *.svelte.[js|ts] file:

async function foo() {
  let x = $derived(await 1);
}

Logs

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 89.95 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.15.1 - ~/.nvm/versions/node/v22.15.1/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.15.1/bin/npm
    pnpm: 10.11.0 - ~/.nvm/versions/node/v22.15.1/bin/pnpm
    bun: 1.0.10 - ~/.bun/bin/bun
  Browsers:
    Chrome: 138.0.7204.101
    Chrome Canary: 124.0.6316.0
    Safari: 18.5
    Safari Technology Preview: 18.4
  npmPackages:
    @sveltejs/adapter-auto: ^6.0.0 => 6.0.1 
    @sveltejs/kit: ^2.22.0 => 2.22.5 
    @sveltejs/vite-plugin-svelte: ^6.0.0 => 6.0.0 
    svelte: https://pkg.pr.new/svelte@15844 => 5.28.2 
    vite: ^7.0.4 => 7.0.4

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