Menci / vite-plugin-top-level-await

Transform code to support top-level await in normal browsers for Vite.
MIT License
251 stars 14 forks source link

Android webview #20

Closed zanzara closed 1 year ago

zanzara commented 1 year ago

Seems to be, that this doesn't work for Android's webview (vue->vite->capacitor->android-Studio)

Still have to use API31 (Android12) as minimum for top level awaits and browser-target must be es2022

Can anyone confirm?

Menci commented 1 year ago

Could you test your bundle with Chrome with the same version? Or could you connect to the WebView with remote inspector (chrome://inspect) to see what happened?

zanzara commented 1 year ago

No, unfortunately not. The same sources are running fine with this toolchain (vue->vite->electron21) w/o vite-plugin-top-level-await plugin.

The issue is, that browser traget chrome89is sufficient for top level await, but a vanilla webview is still below that version. So I need to got up to API31 (Andriod12) in the SDK/emulator to have at least a webview version arround 90

zanzara commented 1 year ago

I did now furhter testing. If I set such browser targets ie. browser: [ 'edge88', 'firefox78', 'chrome87' ,'es2019' , 'safari13.1'], then I can't even bundle my project w/o errors mesg.

[vite:esbuild-transpile] Transform failed with 2 errors:
assets/database.14e162eb.js:27746:19: ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")

although having this vite-plugin-top-level-await plugin installed?

"devDependencies": {
    "vite-plugin-top-level-await": "^1.2.2"
    }

Any ideas? What I'm doing wrong ?

Menci commented 1 year ago

Please post your project for reproduce

zanzara commented 1 year ago

You can close this. I had no success at all - and due to that - I refactored the code eliminating those top level awaits. Sad. :-(