|
| 1 | +# @happykit/flags |
| 2 | + |
| 3 | +## 3.0.0 |
| 4 | + |
| 5 | +### Major Changes |
| 6 | + |
| 7 | +- 1822587: BREAKING CHANGE: Configuration overhaul |
| 8 | + |
| 9 | + ### What |
| 10 | + |
| 11 | + This release changes HappyKit's configuration approach. |
| 12 | + |
| 13 | + Previously you had to create a `flags.config.js` file and import it into your `pages/_app.js` and into every middleware that wanted to use feature flags. If you were using your own `AppFlags` type, you also had to pass this type every time you invoked `getFlags()`, `useFlags()` or `getEdgeFlags()`. And the configuration options for client-, server- and edge were mixed together into a single `flags.config.js` file. |
| 14 | + |
| 15 | + ### Why |
| 16 | + |
| 17 | + This release replaces the existing configuration approach with a new one. This new approach configuration prepares happykit for upcoming features. |
| 18 | + |
| 19 | + ### How |
| 20 | + |
| 21 | + #### 1. Add `flags` folder |
| 22 | + |
| 23 | + Follow the updated [Setup](https://github.com/happykit/flags/tree/master/package#setup) instructions to create the `flags` folder in your own application, and fill it with. |
| 24 | + |
| 25 | + After this step, you should have |
| 26 | + |
| 27 | + - `./flags/config.ts` which exports a configuration |
| 28 | + - `./flags/client.ts` which exports a `useFlags` function |
| 29 | + - `./flags/server.ts` which exports a `getFlags` function |
| 30 | + - `./flags/edge.ts` which exports a `getEdgeFlags` function |
| 31 | + |
| 32 | + #### 2. Set up absolute imports |
| 33 | + |
| 34 | + Enable Absolute Imports as described [here](https://github.com/happykit/flags/tree/master/package#absolute-imports). |
| 35 | + |
| 36 | + #### 3. Adapt your imports |
| 37 | + |
| 38 | + Then change the application code in your `pages/` folder to use these functions from your `flags/` folder instead of from `@happykit/flags`: |
| 39 | + |
| 40 | + ```diff |
| 41 | + - import { useFlags } from "@happykit/flags/client" |
| 42 | + + import { useFlags } from "flags/client" |
| 43 | + ``` |
| 44 | + |
| 45 | + ```diff |
| 46 | + - import { getFlags } from "@happykit/flags/server" |
| 47 | + + import { getFlags } from "flags/server" |
| 48 | + ``` |
| 49 | + |
| 50 | + ```diff |
| 51 | + - import { getEdgeFlags } from "@happykit/flags/edge" |
| 52 | + + import { getEdgeFlags } from "flags/edge" |
| 53 | + ``` |
| 54 | + |
| 55 | + _Note that because of the absolute imports we configured in step 2, all imports from `"flags/_"` will use the local flags folder you created in step 1.\* |
| 56 | + |
| 57 | + #### 4. Delete your old setup |
| 58 | + |
| 59 | + We can now delete the old setup since we no longer need it |
| 60 | + |
| 61 | + - delete `flags.config.js` |
| 62 | + - remove the `flags.config` import from your `pages/_app` file |
| 63 | + - you might be able to delete the `pages/_app` file if it's not doing anything else anymore |
| 64 | + - remove the import of `flags.config` from your middleware |
0 commit comments