I’m building a site with stencil and all is going well, except I’ve noticed that ion-alert and ion-toast are erroring but only in the prod build.
That is to say, when I’m developing using npm start all works fine, my alert looks like this:

And there are no errors.
However once I build the app to deploy with npm run prod which calls stencil build --prerender then the alert doesn’t have a message, and throws a js error.


ion-toast has the same behavior, working in dev, throwing the same error and not showing the message after build. I tried building without prerender, and the same behavior persists.
I have no idea how to debug this since it works during development, and the error is thrown in compiled/minified code.
The way I’m using the alert is pretty straight forward:
alert(message: string, header?: string, subheader?: string) {
return new Promise(resolve => {
const alert = document.createElement('ion-alert');
if (header) {
alert.header = header;
}
if (subheader) {
alert.subHeader = subheader;
}
alert.message = message;
alert.buttons = [
{
text: 'Okay',
handler: () => {
resolve(true);
}
}
];
document.body.appendChild(alert);
return alert.present();
});
}
Any ideas?