wails
wails copied to clipboard
esbuild.target in vite.config is ignored when using wails dev but not when using npm run dev
Description
When starting the project using wails dev
the esbuild.target
property of vite.config
is ignored and is always set to "chrome87", "edge88", "es2020", "firefox78", "safari13" + 2 overrides
.
Which causes features like Top-level await
to not work.
The whole of the error message read as such
-> wails dev
Wails CLI v2.9.1
Executing: go mod tidy
• Generating bindings: Done.
• Installing frontend dependencies: Done.
• Compiling frontend:
> [email protected] build
> vue-tsc --noEmit && vite build
vite v3.2.10 building for production...
transforming...
✓ 18 modules transformed.
[vite:esbuild-transpile] Transform failed with 1 error:
assets/index.9363a9a2.js:5871:0: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari13" + 2 overrides)
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari13" + 2 overrides)
5868|
5869| const style = '';
5870|
| ^
5871| await new Promise((resolve) => {
| ^
5872| setTimeout(() => {
error during build:
Error: Transform failed with 1 error:
assets/index.9363a9a2.js:5871:0: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari13" + 2 overrides)
.... <traces>
There are no errors and the app runs as expected when i first cd
into frontend
and then run npm run dev
And this is the error message that i get when i intentionally set esbuild.target
to es2020
and then run npm run dev
-> npm run dev
> [email protected] dev
> vite
VITE v3.2.10 ready in 362 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
18:48:59 [vite] Internal server error: Transform failed with 1 error:
C:/uni/serbest/repro/frontend/src/main.ts:5:0: ERROR: Top-level await is not available in the configured target environment ("es2020")
Plugin: vite:esbuild
File: C:/uni/serbest/repro/frontend/src/main.ts:5:0
Top-level await is not available in the configured target environment ("es2020")
2 | import App from "./App.vue";
3 | import "./style.css";
4 |
| ^
5 | await new Promise<void>((resolve) => {
| ^
6 | setTimeout(() => {
.... <traces>
To Reproduce
- Started a new project with
wails init -n repro -t vue-ts
(didn't try other templates) - Changed the
esbuild.target
toesnext
- Tried to use Top-level await which is only availble after es2022
- Ran
wails dev
fails withTop-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari13" + 2 overrides)
- cd into
frontend
rannpm run dev
works without issues
Expected behaviour
My vite.config
should be respected and the app should ran as expected
Screenshots
No response
Attempted Fixes
No response
System Details
# Wails
Version | v2.9.1
# System
┌───────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS | Windows 10 Home <- is actually Windows 11 Home |
| Version | 2009 (Build: 22631) |
| ID | 23H2 |
| Go Version | go1.22.3 <- is actually 1.22.6 |
| Platform | windows |
| Architecture | amd64 |
| CPU | AMD Ryzen 7 5800H with Radeon Graphics |
| GPU | AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.) - Driver: 27.20.14064.11001 |
| Memory | 16GB |
└───────────────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version |
| WebView2 | N/A | Installed | 127.0.2651.105 |
| Nodejs | N/A | Installed | 20.11.0 |
| npm | N/A | Installed | 10.2.4 |
| *upx | N/A | Available | |
| *nsis | N/A | Available | |
└─────────────── * - Optional Dependency ────────────────┘
# Diagnosis
Optional package(s) installation details:
- upx : Available at https://upx.github.io/
- nsis : More info at https://wails.io/docs/guides/windows-installer/
Additional context
No response