remove class-validator and rejigger types loading to shrink bundles - #3312
danoswaltCL wants to merge 2 commits into
Conversation
…update quicktest to include easy lite lib testing
There was a problem hiding this comment.
🟡 Changes recommended
The new lite quick-test HTTP client and scripts have correctness issues that can cause runtime failures (header normalization in fetch wrapper; build-skip logic in quicktest scripts).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refactors the JS clientlib to import only the needed upgrade_types submodules (interfaces/enums) so the bundled SDK can avoid pulling in class-validator, significantly shrinking the “lite” bundle; it also dedupes tslib in the webpack build and improves local smoke-testing for the lite bundle.
Changes:
- Switches many
upgrade_typesimports toupgrade_types/Experiment/{interfaces,enums}and introduces a localBINARY_REWARD_VALUEenum to avoid importing reward types fromupgrade_types. - Forces webpack to resolve a single physical
tslibto prevent double-bundling. - Adds a lite-bundle quick test path (BYO HTTP client) and a minimal
fetch-basedIHttpClientWrapperfor smoke tests.
File summaries
| File | Description |
|---|---|
| clientlibs/js/webpack.config.ts | Adds a tslib alias to prevent webpack from bundling multiple tslib copies. |
| clientlibs/js/tsconfig.json | Adjusts TS project root/paths and includes quick test files for typechecking. |
| clientlibs/js/src/UpGradeClient/UpgradeClient.ts | Repoints type imports to narrower upgrade_types/Experiment/* modules and swaps BINARY_REWARD_VALUE to a local enum. |
| clientlibs/js/src/types/requests.ts | Updates enum import to upgrade_types/Experiment/enums. |
| clientlibs/js/src/types/Interfaces.ts | Updates enum import to upgrade_types/Experiment/enums. |
| clientlibs/js/src/types/enums.ts | Adds UpGradeClientEnums.BINARY_REWARD_VALUE enum for SDK consumers. |
| clientlibs/js/src/index.ts | Updates named export imports to narrower upgrade_types/Experiment/* modules. |
| clientlibs/js/src/DataService/DataService.ts | Updates assignment type import to upgrade_types/Experiment/interfaces. |
| clientlibs/js/src/Assignment/Assignment.ts | Splits interface/enums imports to upgrade_types/Experiment/{interfaces,enums}. |
| clientlibs/js/src/ApiService/ApiService.ts | Updates request/log type imports to upgrade_types/Experiment/interfaces. |
| clientlibs/js/quickTestLiteHttpClient.ts | Adds a minimal fetch-based HTTP client wrapper for lite bundle smoke testing. |
| clientlibs/js/quickTest.ts | Adds variant selection to test node vs lite bundle and unifies error logging across HTTP clients. |
| clientlibs/js/package.json | Adds quicktest:lite and updates quicktest scripts. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
It seems unnecessary to define an enum in two places, which we'd have to keep in sync manually. The |
|
i didn't think about the fact that the mooclet-removal already does the major work here in removing class-validator as a factor at all in upgrade_types, and it does do this enum more sensibly, and the build reflects that because it's 44kb instead 400+. There are a couple other smaller wins in this PR that bring it down to ~36kb, but might as well hold off on this one until the mooclet-removal pr is in. |
removing the need for UpgradeClient.BINARY_REWARD_VALUE as an import from upgrade_types allows for rejiggering the building of types so we can slice out
class-validatorfrom our bundle, which hugely reduces the bundle size (theliteversion used by cli-services will go from 400kb to 36kb, it was really that bad)also removes a double-bundling of tslib which was apparently happening 🤷
also quicktest now has a good built-in way of testing the
litebundle