Closed bensaufley closed 1 year ago
The Vite example in this repo will ship PropTypes to prod when npm run build is run.
Are you sure? As far as I can see all propTypes in the production build are empty. I also, can't see any console errors related to prop types in production build (while they show as expected in dev mode).
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.
Duplicates
Latest version
Summary 💡
I'd like to be able to develop without having to wrestle with third-party PropTypes that provide false alarms, and to not ship PropTypes in Prod while using Vite.
Examples 🌈
The Vite example in this repo will ship PropTypes to prod when
npm run build
is run.Motivation 🔦
This project is listed on the Preact website as a Preact-compatible library, and there's even a Preact example directory. I've worked with Preact long enough to know that asking for better Preact support is usually a losing battle, but PropTypes are superfluous, and don't play nice with, for example, Preact's signals (to reproduce, simply pass a signal into mui like
<Typography>{mySignal}</Typography>
and PropTypes will complain that it's not aReactNode
—this can be patched in TS, but not easily in PropTypes). Since I'm using TypeScript, PropTypes are extra-unnecessary and I'd like to be able to usemui
without including PropTypes even in dev.Beyond that, though, I'm using Vite, and while both the React and Preact vite plugins allow use of Babel plugins to, for example, strip PropTypes from a Prod build, but that plugin only transforms my [p]react and does not touch vendor files. There's a rollup plugin but it doesn't seem widely used and it doesn't work for me. So it seems like anyone who is currently using mui with Vite is likely shipping proptype validation to prod. That seems non-ideal and I would love it if it could be somehow decoupled.