This repo showcases an issue with rsbuild where LottiePlayer (a web component) works fine in dev, but crashes the app in production. This issue seems to happen only in conjunction with imports from other libraries (e.g., in this repro we're importing also @datadog/browser-logs
). Removing the additional library imports make the app work fine both in dev and in prod. If I had to guess, this seems to be a minifaction issue?
Install the dependencies:
pnpm install
Start the dev server:
pnpm dev
Check the app: you'll see it works fine.
Build and preview the app for production:
pnpm build & pnpm preview
You'll see it erroring out with TypeError: Cannot read properties of undefined (reading 'createElement')
.
Try removing the following:
import { datadogLogs } from "@datadog/browser-logs";
console.log("@datadog/browser-logs", datadogLogs);
And try building and previewing again: you'll see that the app works fine.