worker-template-mysql icon indicating copy to clipboard operation
worker-template-mysql copied to clipboard

Top-level await is not available in the configured target

Open delivrjs opened this issue 2 years ago • 6 comments

Hello, I am facing following error when trying to publish it to cloudflare workers

✘ [ERROR] Top-level await is not available in the configured target environment ("es2020")

    dist/index.mjs:8:1790:
      8 │ ...)});let c=i.level||Ae,_=new Y(r,c,{handlers:s});T.loggers.set(r,_)}}await Qe(X);var dn=await async function(){return{LogLevels:f,Logger:Y,ha...
        ╵                                                                        ~~~~~

✘ [ERROR] Top-level await is not available in the configured target environment ("es2020")

    dist/index.mjs:8:1809:
      8 │ ...Ae,_=new Y(r,c,{handlers:s});T.loggers.set(r,_)}}await Qe(X);var dn=await async function(){return{LogLevels:f,Logger:Y,handlers:_n,LoggerCon...
        ╵                                                                        ~~~~~


✘ [ERROR] Build failed with 2 errors:

  dist/index.mjs:8:1790: ERROR: Top-level await is not available in the configured target
  environment ("es2020")
  dist/index.mjs:8:1809: ERROR: Top-level await is not available in the configured target
  environment ("es2020")

The problem seems to be arising from here:

await setup(DEFAULT_CONFIG);
const mod = await async function () {
    return {
        LogLevels: LogLevels,
        Logger: Logger,
        handlers: handlers1,
        LoggerConfig: LoggerConfig,
        getLogger: getLogger,
        debug: debug,
        info: info,
        warning: warning,
        error: error,
        critical: critical,
        setup: setup
    };
}();

How do I enable Top-level await or how to make it work @nilslice ?

delivrjs avatar May 28 '22 13:05 delivrjs