diff --git a/packages/nitro/src/targets/worker.ts b/packages/nitro/src/targets/worker.ts index 687d4a25e8..f0dd931831 100644 --- a/packages/nitro/src/targets/worker.ts +++ b/packages/nitro/src/targets/worker.ts @@ -5,8 +5,8 @@ import { SLSTarget } from '../config' const polyfill = ` const exports = {}; const module = { exports }; -const global = { process: {} }; -const window = global; +const global = typeof globalThis !== 'undefined' ? globalThis : "undefined" !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; +global.process = global.process || {}; (function(){const o=Date.now(),t=()=>Date.now()-o;global.process.hrtime=o=>{const e=Math.floor(.001*(Date.now()-t())),n=.001*t();let a=Math.floor(n)+e,r=Math.floor(n%1*1e9);return o&&(a-=o[0],r-=o[1],r<0&&(a--,r+=1e9)),[a,r]};})(); `