v3.0.0
Major Changes
-
1822587: BREAKING CHANGE: Configuration overhaul
What
This release changes HappyKit's configuration approach.
Previously you had to create a
flags.config.jsfile and import it into yourpages/_app.jsand into every middleware that wanted to use feature flags. If you were using your ownAppFlagstype, you also had to pass this type every time you invokedgetFlags(),useFlags()orgetEdgeFlags(). And the configuration options for client-, server- and edge were mixed together into a singleflags.config.jsfile.Why
This release replaces the existing configuration approach with a new one. This new approach configuration prepares happykit for upcoming features.
How
1. Add
flagsfolderFollow the updated Setup instructions to create the
flagsfolder in your own application, and fill it with.After this step, you should have
./flags/config.tswhich exports a configuration./flags/client.tswhich exports auseFlagsfunction./flags/server.tswhich exports agetFlagsfunction./flags/edge.tswhich exports agetEdgeFlagsfunction
2. Set up absolute imports
Enable Absolute Imports as described here.
3. Adapt your imports
Then change the application code in your
pages/folder to use these functions from yourflags/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.*4. Delete your old setup
We can now delete the old setup since we no longer need it
- delete
flags.config.js - remove the
flags.configimport from yourpages/_appfile- you might be able to delete the
pages/_appfile if it's not doing anything else anymore
- you might be able to delete the
- remove the import of
flags.configfrom your middleware