Skip to content

Commit

Permalink
docs: env info (mobxjs#3188)
Browse files Browse the repository at this point in the history
* Add env info

* typo
  • Loading branch information
urugator authored Nov 24, 2021
1 parent 6b83fa2 commit 50b8010
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ There are two types of React bindings, `mobx-react-lite` supports only functiona

## Use spec compliant transpilation for class properties

⚠️ **Warning:** When using MobX with TypeScript and Babel, and you plan to use classes; make sure to update your configuration to use a TC-39 spec compliant transpilation for class fields, since this is not the default. Without this, class fields cannot be made observable before they are initialized.
⚠️ **Warning:** When using MobX with TypeScript or Babel, and you plan to use classes; make sure to update your configuration to use a TC-39 spec compliant transpilation for class fields, since this is not the default. Without this, class fields cannot be made observable before they are initialized.

- **TypeScript**: Set the compiler option `"useDefineForClassFields": true`.
- **Babel**: Make sure to use at least version 7.12, with the following configuration:
Expand Down Expand Up @@ -56,6 +56,16 @@ If you have used MobX before, or if you followed online tutorials, you probably
In MobX 6, we have chosen to move away from decorators by default, for maximum compatibility with standard JavaScript.
They can still be used if you [enable them](enabling-decorators.md) though.

## Development vs production

Unless you're using pre-build distribution ending with `.[production|development].min.js`, Mobx uses `process.env.NODE_ENV` variable to detect the environment. Make sure it's set to `"production"` on production. This is usually done by your favourite bundler:
[webpack](https://reactjs.org/docs/optimizing-performance.html#webpack)
[Rollup](https://reactjs.org/docs/optimizing-performance.html#rollup)
[Browserify](https://reactjs.org/docs/optimizing-performance.html#browserify)
[Brunch](https://reactjs.org/docs/optimizing-performance.html#brunch)

Most of the safety checks, like [`enforceAction`](https://mobx.js.org/configuration.html#enforceactions) and similar, happens on development only.

## MobX on other frameworks / platforms

- [MobX.dart](https://mobx.netlify.app/): MobX for Flutter / Dart
Expand Down

0 comments on commit 50b8010

Please sign in to comment.