Why MobX might work for vite dev
and not vite build
production
#3916
Unanswered
StephenHaney
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Documenting for future searchers:
@vitejs/plugin-react-swc
which doesn't support ES decorators yet, so we've been usingtsDecorators: true
@vitejs/plugin-react-swc
only runs invite dev
, it's not used for build@
withouttsDecorators: true
accessor
words in production (as far as I can tell)So you can very easily run into a situation where you're using legacy decorators for dev mode and ES decorators for production builds. And your production build won't warn about needing to update your MobX syntax to use
accessor
. So your prod build might just mysteriously have no observables, although it was working fine in dev!My solution is to switch to
@vitejs/plugin-react
(not SWC) so that I can run ES decorators in both dev and prod.I hope this post saves someone else some debugging time! This is the first time that vite taking different paths for dev and build has bit me.
Beta Was this translation helpful? Give feedback.
All reactions