Skip to content

iife with awaits in development only #20087

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

Closed
7 tasks done
crabvk opened this issue May 22, 2025 · 3 comments
Closed
7 tasks done

iife with awaits in development only #20087

crabvk opened this issue May 22, 2025 · 3 comments

Comments

@crabvk
Copy link

crabvk commented May 22, 2025

Describe the bug

I'm using iife as the build format. My code contains some awaits, but only inside

if (import.meta.env.DEV) {
  // Some `await`s are here.
}

Trying to build project with yarn run vite build -m production, getting error:

error during build:
Module format "iife" does not support top-level await. Use the "es" or "system" output formats rather.

Expected the code inside the if statement to be ignored in production build.

Reproduction

https://stackblitz.com/edit/vitejs-vite-hstwzwv1

Steps to reproduce

No response

System Info

System:
    OS: Linux 6.14 Artix Linux
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 24.55 GB / 31.25 GB
    Container: Yes
    Shell: 4.0.2 - /usr/bin/fish
  Binaries:
    Node: 22.16.0 - ~/.local/share/mise/installs/node/22.16.0/bin/node
    Yarn: 4.9.1 - ~/.npm-packages/bin/yarn
    npm: 10.9.2 - ~/.local/share/mise/installs/node/22.16.0/bin/npm
  Browsers:
    Chromium: 136.0.7103.113

Used Package Manager

yarn

Logs

No response

Validations

Copy link

Hello @crabvk. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@crabvk
Copy link
Author

crabvk commented May 25, 2025

Minimal reproduction: https://stackblitz.com/edit/vitejs-vite-hstwzwv1

Copy link

Hello @crabvk. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants