You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Workers supports uploading ES Module syntax now. This might be lightly documented in API docs, but ESM-based workers are uploaded with Content-Type: application/javascript+module, as seen when uploading from the Workers editor in the dashboard.
Change the call signature of UploadWorker to UploadWorker(ctx context.Context, requestParams *WorkerRequestParams, data *WorkerScriptParams), and ignore the Bindings field.
Attempting to upload a valid worker without this sort of change results in a response:
{
"code": 10021,
"message": "Uncaught SyntaxError: Unexpected token 'export'\n at line 1\n"
}
Just here to agree that this is a infuriating blocker when trying to use Cloud Workers and deploy them via Terraform. Notably because it's the default format outputted by Wrangler.
Current cloudflare-go version
0.31.0
Description
Workers supports uploading ES Module syntax now. This might be lightly documented in API docs, but ESM-based workers are uploaded with
Content-Type: application/javascript+module
, as seen when uploading from the Workers editor in the dashboard.cloudflare-go doesn't have any way to make the distinction, and would need to be added around here for UploadWorker and here via UploadWorkerWithBindings
The likely best option, in my opinion, is to
Module: bool
field toWorkerScriptParams
UploadWorker
toUploadWorker(ctx context.Context, requestParams *WorkerRequestParams, data *WorkerScriptParams)
, and ignore theBindings
field.Attempting to upload a valid worker without this sort of change results in a response:
Use cases
Uploading Worker assets from Terraform
Potential cloudflare-go usage
References
cloudflare_worker_script
resources being module syntax terraform-provider-cloudflare#1417The text was updated successfully, but these errors were encountered: