Switch to configcat-js-ssr to allow the plugin work in SSR setups. (configcat-js uses XMLHttpRequest under the hood, which is only available in browsers but not in backend runtimes like Node.js. As opposed to that, configcat-js-ssr uses Axios, which abstracts away HTTP access and is able to use the HTTP API available on the specific platform.)
Don't include configcat-js-ssr into dist bundles. I think it's best to leave it to the end user's bundler to deal with including the necessary packages in their final app bundle.
Fix ConfigCat client initialization & cleanup. Initialization was buggy because of the behavior of getClient:
[...] subsequent calls to getClient() with the same SDK Key return a shared client instance, which was set up by the first call.
Also, the client object was disposed at the wrong place. It should be active until the Vue app is alive, not until the unmount of a FeatureWrapper component, which can happen earlier.
Improve feature flag change detection. The original implementation doesn't take the user object into account in the configChanged handler. The new snapshot API makes this possible.
Remove the dist directory from version control.
It'd be also nice to use TypeScript in the project but that looks a bit tricky, so let's address this later, in a separate PR.
This PR proposes a few improvements and fixes:
configcat-js-ssr
to allow the plugin work in SSR setups. (configcat-js
usesXMLHttpRequest
under the hood, which is only available in browsers but not in backend runtimes like Node.js. As opposed to that,configcat-js-ssr
uses Axios, which abstracts away HTTP access and is able to use the HTTP API available on the specific platform.)configcat-js-ssr
into dist bundles. I think it's best to leave it to the end user's bundler to deal with including the necessary packages in their final app bundle.Fix ConfigCat client initialization & cleanup. Initialization was buggy because of the behavior of
getClient
:Also, the client object was disposed at the wrong place. It should be active until the Vue app is alive, not until the unmount of a
FeatureWrapper
component, which can happen earlier.configChanged
handler. The new snapshot API makes this possible.It'd be also nice to use TypeScript in the project but that looks a bit tricky, so let's address this later, in a separate PR.