@happykit/flags |
---|
major |
BREAKING CHANGE: Configuration overhaul
This release changes HappyKit's configuration approach.
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.
This release replaces the existing configuration approach with a new one. This new approach configuration prepares happykit for upcoming features.
Follow the updated Setup instructions to create the flags
folder in your own application, and fill it with.
After this step, you should have
./flags/config.ts
which exports a configuration./flags/client.ts
which exports auseFlags
function./flags/server.ts
which exports agetFlags
function./flags/edge.ts
which exports agetEdgeFlags
function
Enable Absolute Imports as described here.
Then change the application code in your pages/
folder to use these functions from your flags/
folder instead of from @happykit/flags
:
- import { useFlags } from "@happykit/flags/client"
+ import { useFlags } from "flags/client"
- import { getFlags } from "@happykit/flags/server"
+ import { getFlags } from "flags/server"
- import { getEdgeFlags } from "@happykit/flags/edge"
+ import { getEdgeFlags } from "flags/edge"
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.
We can now delete the old setup since we no longer need it
- delete
flags.config.js
- remove the
flags.config
import from yourpages/_app
file- you might be able to delete the
pages/_app
file if it's not doing anything else anymore
- you might be able to delete the
- remove the import of
flags.config
from your middleware