Skip to content

@vitejs/plugin-legacy warning Top-level await is not available when renderModernChunks is false #22521

@wherewhere

Description

@wherewhere

Describe the bug

When I build a project with @vitejs/plugin-legacy by set

legacy({
    targets: "Edge >= 18",
    polyfills: true,
    renderModernChunks: false
})

It warning [TOLERATED_TRANSFORM] Top-level await is not available in the configured target environment.

It should not warning since renderModernChunks is false so it will not have any effect. And if I set modernTargets: "defaults", it not warning Top-level await is not available but warning plugin-legacy 'modernTargets' option overrode the builtin targets of modern chunks. Some versions of browsers between legacy and modern may not be supported.

Reproduction

https://github.com/wherewhere/VueForUWP

Steps to reproduce

  • Create a vite project with @vitejs/plugin-legacy
  • Set targets: "Edge >= 18"
  • Write some top await
  • Build it

System Info

System:
  OS: Windows 11 10.0.26200
  CPU: (8) x64 Intel(R) Core(TM) Ultra 7 266V
  Memory: 2.00 GB / 15.72 GB
Binaries:
  Node: 26.1.0 - C:\Program Files\nodejs\node.EXE
  Yarn: 1.22.22 - C:\Users\qq251\AppData\Roaming\npm\yarn.CMD
  npm: 11.13.0 - C:\Program Files\nodejs\npm.CMD
  bun: 1.3.10 - C:\Users\qq251\AppData\Roaming\npm\bun.CMD
npmPackages:
  @vitejs/plugin-legacy: ^8.0.0 => 8.0.2 
  @vitejs/plugin-vue: ^6.0.0 => 6.0.7 
  vite: ^8.0.0 => 8.0.14

Used Package Manager

npm

Logs

Click to expand!
> vue-uwp@0.0.1 build
> vite build

vite v8.0.14 building client environment for production...
✓ 89 modules transformed.
computing gzip size...
dist/index.html                                             0.81 kB │ gzip:  0.43 kB
dist/assets/Symbols-Cnx9HBaY.ttf                           47.48 kB
dist/assets/base.min-DFyWONOv.js                          331.39 kB
dist/assets/ui.min-Cg9LWWJn.js                            872.11 kB
dist/assets/WinJSControl-legacy-Cwrq1Znq.js                 0.70 kB │ gzip:  0.48 kB │ map:   3.30 kB
dist/assets/NotFoundView-legacy-Bz9bLDXs.js                 1.87 kB │ gzip:  1.18 kB │ map:   4.65 kB
dist/assets/IndexView-legacy-Dl3G5J8V.js                    7.12 kB │ gzip:  2.01 kB │ map:  19.23 kB
dist/assets/theme-legacy-CVnodPOl.js                       11.04 kB │ gzip:  4.92 kB │ map:  79.74 kB
dist/assets/package-legacy-DT7ZUDks.js                     17.31 kB │ gzip:  6.64 kB │ map:  58.11 kB
dist/assets/vue-router-legacy-3HN-QJuv.js                  25.25 kB │ gzip:  9.69 kB │ map: 146.60 kB
dist/assets/SettingsView-legacy-BhVMz_yx.js                45.87 kB │ gzip: 11.19 kB │ map: 103.63 kB
dist/assets/_plugin-vue_export-helper-legacy-BmFU7m2N.js   59.28 kB │ gzip: 23.54 kB │ map: 442.15 kB
dist/assets/polyfills-legacy-Ds68o5DC.js                  108.22 kB │ gzip: 39.52 kB │ map: 500.85 kB
dist/assets/index-legacy-wFQTuR2H.js                      296.89 kB │ gzip: 31.96 kB │ map:  52.72 kB

[TOLERATED_TRANSFORM] Top-level await is not available in the configured target environment.
    ╭─[ index.ts:18:1 ]
    │
 18 │ await useScriptAsync(head, { src: baseJsUrl });
    │ ───────────────────────┬──────────────────────  
    │                        ╰──────────────────────── 
────╯

[TOLERATED_TRANSFORM] Top-level await is not available in the configured target environment.
    ╭─[ index.ts:20:1 ]
    │
 20 │ await useScriptAsync(head, { src: uiJsUrl });
    │ ──────────────────────┬─────────────────────  
    │                       ╰─────────────────────── 
────╯

✓ built in 7.77s

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions