we haven't found the root cause. initially we do clear cache / incognito mode. then we don't see that error. later someone suggested to check our index.html file having one line of code cacheBust: "{{cachebust}}" available or not. in our case it has some hardcoded text. so then we removed that line updated with above line. then we dont see that error. I am not sure, this is the root cause.
Isnt this approach kind of wrong?
Like, there are few red flags i see.
1. Using commonjs require in a pluggable widget(which runs on the browser) is not something that can be done - sure it will build but it wont work. That is a backend package that you are using!
2. saving a file to you filesystem using browser APIs is something that puts me off. (I believe that Browser doest have access to the Filesystem directly!)
If you have time can you try the below approaches?
1. Change the library approach that you are using to create and save the file.
use the Browser Blob API to create a blob data, then write it to an in-memory file which you attach it to you DOM under an onclick which on click can present itself for downloading. See the code snippet below (you can use the JS part in your widget code)
<!DOCTYPE html>
<html>
<head>
<title>Generate a Text File</title>
</head>
<body>
<button onclick='download(blob,"dummy-file.txt");'>Download</button>
<script type="text/javascript">
// create the text file as a Blob:
// your content goes here!!!
var blob = new Blob(["hello world"],{type: "text/plain"});
function download(blob,name) {
var url = URL.createObjectURL(blob),
div = document.createElement("div"),
anch = document.createElement("a");
document.body.appendChild(div);
div.appendChild(anch);
anch.innerHTML = " ";
div.style.width = "0";
div.style.height = "0";
anch.href = url;
anch.download = name;
var ev = new MouseEvent("click",{});
anch.dispatchEvent(ev);
document.body.removeChild(div);
}
</script>
</body>
</html>
2. Make a Microflow trigger which saves the file on the server. then you can present a download button to the user.
good luck.
Is your problem solved now?Is your problem solved now?