Why MobX might work for vite dev and not vite build production
#3916
Unanswered
StephenHaney
asked this question in
General
Replies: 1 comment 2 replies
|
I managed to resolve this issue by prividing an empty array Sample configuration: |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Documenting for future searchers:
@vitejs/plugin-react-swcwhich doesn't support ES decorators yet, so we've been usingtsDecorators: true@vitejs/plugin-react-swconly runs invite dev, it's not used for build@withouttsDecorators: trueaccessorwords 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.
All reactions