Using xmlbuilder2 in a webworker or Cloudflare Worker? #77
Replies: 2 comments
-
I'm generating xml files in a SketchApp plugin (it is running in a Safari sandbox, or something?! But not in a "real web browser") and getting the same error thrown: "Can't find variable: window". EDIT: removing EDIT: got it working with this tweak to the webpack config: config.resolve.aliasFields = ["sketch"];
config.resolve.mainFields = ["sketch", "module", "main"];
config.resolve.aliasFields = [];
config.resolve.mainFields = ["module", "main"]; |
Beta Was this translation helpful? Give feedback.
-
This should be fixed in version |
Beta Was this translation helpful? Give feedback.
-
I am using Cloudflare Workers, which is similar to AWS Lambda or Azure Functions but is not the "full" node runtime. As a result, the build process is a bit strange and webpack targets
webworker
- see this section of the Worker docs if you're at all currious.The problem I'm facing is that for a reason I can't understand, the code below (specifically
create(...
) triggers an error:ReferenceError: window is not defined
I don't understand why this is happening exactly, but I can only imagine that some execution path within
xmlbuilder2
perhaps checks for the existence of certain node features (?) and if they are not found it falls back to "browser mode" or something?I'm wondering if anybody can point me in the right direction, tell me if this is completely hopeless, etc.
Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions