Top-level await is not available in the configured target
Opened this issue · 6 comments
delivrjs commented
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 ?
saasryan commented
Same issue, did you find a solution?
on-future commented
+1
delivrjs commented
Same issue, did you find a solution?
Nah man! Hope the author at-least replies @saasryan
SirRodney commented
+1
Hundeklemmen commented
+1
shiyuhang0 commented
change the code likes below, it works for me
let mod
let logger
(async () => {
try {
await setup(DEFAULT_CONFIG);
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
};
}();
logger = mod.getLogger();
} catch (err) {
console.error(err);
}
})();