-
Notifications
You must be signed in to change notification settings - Fork 59
feat(web-global-build): concept + impl? #1366
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @zdunecki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've introduced a new feature that provides global, Immediately Invoked Function Expression (IIFE) builds for the web client providers, specifically for GrowthBook and LaunchDarkly. The primary motivation behind this change is to enable OpenFeature to load as a foundational dependency in web environments, ensuring it's available before other modules are resolved by the browser. This is currently a conceptual implementation to explore its viability.
Highlights
- Global IIFE Builds: Introduced a new build process using Rollup to create global (IIFE) bundles for the GrowthBook and LaunchDarkly web client providers.
- New Build Scripts: Added a 'build:global' script to the package.json of both GrowthBook and LaunchDarkly client providers, enabling easy generation of these new global builds.
- Rollup Configuration: Configured Rollup to handle external dependencies and map them to global variables (e.g., OpenFeature, growthbook, LDClient) for the IIFE output.
- Minified Build Variant: Included minification for the LaunchDarkly global build using @rollup/plugin-terser, optimizing the output size.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a global IIFE build for the GrowthBook and LaunchDarkly web client providers, which is a great addition for users who want to include these providers via a simple <script>
tag. The implementation uses Rollup and looks solid.
My main feedback is to ensure consistency between the two new build configurations. The LaunchDarkly provider build generates both a standard and a minified bundle, which is excellent. I've suggested applying the same pattern to the GrowthBook provider for completeness and better usability.
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import esbuild from 'rollup-plugin-esbuild'; | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
output: { | ||
file: 'dist/global/index.js', | ||
format: 'iife', | ||
name: 'GrowthbookProvider', | ||
globals: { | ||
'@openfeature/web-sdk': 'OpenFeature', | ||
'@growthbook/growthbook': 'growthbook', | ||
}, | ||
sourcemap: true, | ||
}, | ||
external: ['@openfeature/web-sdk', '@growthbook/growthbook'], | ||
plugins: [ | ||
commonjs(), | ||
resolve(), | ||
esbuild({ | ||
target: 'es2017', | ||
tsconfig: './tsconfig.json', | ||
}), | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the launchdarkly-client
provider, it would be beneficial to also generate a minified version of the global build. This improves usability for consumers who want to use a smaller file in production.
You can update this file to produce both bundled and minified versions. Also, remember to add @rollup/plugin-terser
to the devDependencies
in libs/providers/growthbook-client/package.json
.
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import esbuild from 'rollup-plugin-esbuild';
import terser from '@rollup/plugin-terser';
const bundle = {
input: 'src/index.ts',
output: {
file: 'dist/global/index.js',
format: 'iife',
name: 'GrowthbookProvider',
globals: {
'@openfeature/web-sdk': 'OpenFeature',
'@growthbook/growthbook': 'growthbook',
},
sourcemap: true,
},
external: ['@openfeature/web-sdk', '@growthbook/growthbook'],
plugins: [
commonjs(),
resolve(),
esbuild({
target: 'es2017',
tsconfig: './tsconfig.json',
}),
],
};
export default [
bundle,
{
...bundle,
output: {
...bundle.output,
file: 'dist/global/index.min.js',
},
plugins: [...bundle.plugins, terser()],
},
];
Hey @zduneckim, |
Signed-off-by: Patryk Zdunowski <zdunekhere@gmail.com>
Signed-off-by: Patryk Zdunowski <zdunekhere@gmail.com>
c0d0169
to
b683b6c
Compare
What you think about this? As I said before, it's a concept only - let me know if idea is fine for you. If so, I'll try to fix test issues + find a better build solution and apply DRY. Best, |
Hey @zdunecki sorry for the delay! |
@lukas-reining Can't say when, but I'll try soon. Best, |
This PR
Notes
It's a concept only, I'm not quite sure if OpenFeature Community is likely to follow this idea. If so, I'll update this PR by improving a build process since this repository has a special build system.
How to test
Motivation
Trying to load OpenFeature as a first dependency before browser will resolve any modules.