Skip to content
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

Add isTesting and isDevelopingApp to readme #1031

Merged
merged 1 commit into from
Nov 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,28 @@ if (macroCondition(getOwnConfig().shouldIncludeMinifiedLibrary)) {
<button class="{{macroGetOwnConfig "themeColor"}}">My Themed Button</button>
```

### isTesting, isDevelopingApp

These methods can be used in conjunction with `macroCondition` to tree-shake code for specific environments.

```js
import { isTesting, isDevelopingApp, macroCondition } from '@embroider/macros';

if (macroCondition(isTesting()) {
// some test code - stripped out when not running tests
} else {
// some none-test code
}

if (macroCondition(isDevelopingApp()) {
// some code when app is in development environment - stripped out in production builds
} else {
// some production code
}
```

Note that these can be used in combination - e.g. if you run tests in the production environment, `isTesting()` will be true, but `isDevelopingApp()` will be false.

## Real world examples

Below are a list of addons that have started using `@embroider/macros` so that you can get a feel for common use cases that can be solved via the macro system.
Expand Down