-
Notifications
You must be signed in to change notification settings - Fork 11
Type generating CLI #301
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
Closed
Closed
Type generating CLI #301
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ich doesn't work)
…config` option. (#285) This PR introduces the `config`, which is an user-supplied JSON value that matches a given feature context (similar to targeting). The resolved configuration variant is then passed down to the client SDKs for use.
This PR adds support for remote configuration to the node-sdk.
14dcc78 to
6c9e08b
Compare
8815566 to
62b55a8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a two part PR with a CLI that generates a package
_bucketand updates the browser/react SDK to optionally make use of the_bucketpackage.It's a lot of added complexity, so any suggestions on simplifying would be greatly appreciated.
CLI
This introduces a new minimalistic CLI package which can:
bucket init: writes an almost emptybucket.config.jsonfilebucket features add: add a new feature tobucket.config.jsonand callfeatures generatebucket features generate: write the_bucketpackage out based off ofbucket.config.json.thanks to @Swiftwork for laying the ground work for the CLI!
Browser/React SDK
The goal here has been to keep the option to use both libraries without the generated
_bucketpackage and CLI. There's no way to dotry { import ... from "_bucket" } catch {}because there's no runtime importing going on. At compile-time there's a bundler that runs and resolves all the imported packages. If you import a package that imports from "_bucket" and that module doesn't exist, you'll get an error.So, this introduces two sets of files, for each of the Browser and React SDKs:
_bucket. This set imports from the_bucketpackage and exposes a bunch the same classes/types but with the type arguments filled in.Example:
@bucketco/browser-sdkand@bucketco/browser-sdk/configuredClient.@bucketco/browser-sdkexposes the generic version of the BucketClient:BucketClient<FeatureDefs>and doesn't use the_bucketpackage, while@bucketco/browser-sdk/configuredClientexposes aBucketClientConfiguredwhich already has the types from the generated_bucketpackage inserted along with the list of features (the types get removed at compile time, but since we want the toolbar to show the list of features locally, we also need to include an actual list as opposed to just the types).Similarly, in the ReactSDK we go on the assumption that people will be using the CLI workflow to generate types and this importing
@bucketco/react-sdkwill give you a BucketProvider which already has the types and the feature list loaded in from_bucket. It imports@bucketco/browser-sdk/configuredClientwhich does the hard work. You can still import@bucketco/react/baseBucketProviderto get a vanilla BucketProvider without the types/features loaded in.Why
_bucketI started out with
.bucketbut unfortunately rollup refuses to resolve it. It works for Prisma because they rely on Node.js package resolving while we have to deal with bundlers. Other options could be@bucketco/_generated@bucketco/_generated-configor similarUMD build
Unfortunately, vite doesn't support building a UMD when there are multiple entrypoints. We have multiple entrypoints to allow folks to use the libraries without the generated
_bucketpackage. We can probably work around it if we think it's important.