New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation: Add installation.md note about Next.js #3263
base: main
Are you sure you want to change the base?
Conversation
This adds a note for Next.js users, who (unintuitively) must configure babel even if their project uses typescript.
The most staggering thing is that nowadays you shouldn't need to set this up at all, because these are defaults. But it depends on framework, it's version, it's compilation setup, babel version and presets version ... it's a mess. Btw here: https://babeljs.io/docs/en/babel-plugin-transform-typescript#typescript-compiler-options they state: EDIT based on this: https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/preset.ts "presets": [
["next/babel", { "preset-typescript": { "onlyRemoveTypeImports": true } }]
], |
Just verifying that the above suggested Maybe it should be added to the updated documentation comment? |
@jamieathans Does the issue exist in a fresh up-to-date Next.js setup? |
@kubk Just double checked this again using the following
What I have discovered is just the presence of a minimal
Maybe this implies the issue is with SWC as I also see the following messages in the node dev terminal:
|
This adds a note for Next.js users, who (unintuitively) must configure babel (which is normally not needed at all) even if their project uses typescript. I think this is worth including because Next.js is relatively popular, and following the instructions as stated here simply doesn't work for unclear reasons. I spent the better part of an evening debugging this, only to eventually figure out that Next.js uses babel for compilation even if the project is set up with/written in typescript and doesn't have a babel config file yet.
Had I not had an evening free that I felt like spending on this, I probably would have given up entirely on MobX, as this was my first project to try it out and it seemed to just not work when used as directed (as all typescript-declared class fields without initial values were just mysteriously not tracked by makeAutoObservable)
See #2831 (reply in thread) for related discussion / my journey in debugging this