9 Replies
Workers disables eval / new Function() at a runtime level for security reasons – is that your own authored code or is there any tool transpiling it like that?
may be a tool, i just created a nextjs project and added kv bindings and ran preview:worker
and encountered this error
what do you have on your ./worker-next/index.mjs ?
or is that being generated through babel/tsc/any tool?
(and you're writing your source code in a different file)
yes i guess this could be the reason it's a ts project
check on that tooling - see if it's using any weird tsconfig or tooling
a bunch of code compiled to js
it shouldn't output eval to do a require
if you can get that fixed it should work
ok will look into that
here's the source of code that isn't allowed https://developers.cloudflare.com/workers/runtime-apis/web-standards/#javascript-standards
Cloudflare Docs
JavaScript and web standards · Cloudflare Workers docs
Standardized APIs for use by Workers running on Cloudflare's global network.