denoland / denokv

A self-hosted backend for Deno KV
https://deno.com/kv
MIT License
456 stars 21 forks source link

Issues Top-level await is not available in the configured target environment #58

Closed rinjugatla closed 8 months ago

rinjugatla commented 9 months ago

I tested the code in a minimal environment using vite and get the following error.

X [ERROR] Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)

node_modules/@deno/kv/esm/napi_based.js:34:31:
  34 │ const DEFAULT_NAPI_INTERFACE = await import('./_napi_index.cjs');
     ╵                                ~~~~~

We have prepared the code for testing in the following repository This problem does not occur with min-node, but can be reproduced with min-vite. https://github.com/rinjugatla/denokv-for-issue

This problem could also be solved by installing the following plugin. https://github.com/Menci/vite-plugin-top-level-await

rinjugatla commented 8 months ago

This is a problem due to the configuration on the vite side, so I don't think it is a problem for denokv.