Skip to content

support top-level await in the main process when using the vite plugin #3943

Description

@hab25

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

When I run my electron app that has some top-level await code and is bundled using the vite plugin, I get the following message in my console:

✓ 493 modules transformed.
Module format "cjs" does not support top-level await. Use the "es" or "system" output formats rather.
file: /home/hab25/my/work/react-electron-poc/src/main.ts

Proposed solution

Implementing this probably means implementing the following TODO:

// TODO(erickzhao): Remove this when upgrading to Vite 6 and converting to ESM

Alternatives considered

None

Additional information

No response

Activity

  1. erickzhao commented on May 21, 2025

    @erickzhao
    Member

    Hey @hab25, thanks for the report. As you mentioned in the issue, this is currently blocked on us upgrading our build system to type: module and upgrading to Vite 6. There's a bit of a chicken-and-egg issue right now with making breaking changes for Electron Forge 8 so there's some pending work that needs to be done beforehand. 🙇

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions