Another curious case of empty error messages. This time I am trying to import a JavaScript library, Moment.js, and am getting a failure but no indication of why.
import { loadScript } from "lightning/platformResourceLoader";
import moment from "@salesforce/resourceUrl/moment";
export default class MyComponent extends LightningElement
{
renderedCallback()
{
Promise.all(
[
loadScript(this, moment + '/moment.js')
]
).then(() =>
{
console.log(moment().format());
}
)
.catch(error =>
{
console.error("Failed to load moment! ( " + JSON.stringify(error) + " )");
}
);
}
}
The peculiar part of all this, sure it does fail to load, but the error is just... nothing. An empty object. It's an object, not undefined, just with no properties in it whatsoever:
Failed to load moment! ( {} )
The static resource for Moment.js is set up as a zip file (the .js is inside the zip). The static resource cache control is set to public. A coworker used this exact setup for another project and so far no one has found any issues here so I am at a bit of a loss. What would be causing loadScript to fail here, and why would (as unsurprising as it is) I not get any kind of error feedback?