electron / electron/forge

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

Open
#3,943 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 1h
Merged PRs (30d)
30

Description

### Pre-flight checklist

- [x] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [x] 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:

https://github.com/electron/forge/blob/daa19d66333413f8a2ac44fabfb7dbee1eee6a50/packages/plugin/vite/src/VitePlugin.ts#L1

### Alternatives considered

None

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.