Skip to content

refactor: Added a separate bundle for Json Schema Validator #454

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

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/optimizely-sdk/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Removed `Promise` polyfill from browser entry point ([417](https://github.com/optimizely/javascript-sdk/pull/417)).
- Changed functionality of JSON schema validation in all entry points ([442](https://github.com/optimizely/javascript-sdk/pull/442)).
- Previously, `skipJSONValidation` flag was used by the user to specify whether the JSON object should be validated.
- Now, `skipJSONValidation` has been removed entirely from all entry points. Instead, a user will need to import `jsonSchemaValidator` from `@optimizely/optimizely-sdk/lib/utils/json_schema_validator` and pass it to `createInstance` to perform validation as shown below:
- Now, `skipJSONValidation` has been removed entirely from all entry points. Instead, a user will need to import `jsonSchemaValidator` from `@optimizely/optimizely-sdk/dist/optimizely.json_schema_validator.min.js` and pass it to `createInstance` to perform validation as shown below:

```js
const optimizelySDK = require('@optimizely/optimizely-sdk');
const jsonSchemaValidator = require('@optimizely/optimizely-sdk/lib/utils/json_schema_validator');
const jsonSchemaValidator = require('@optimizely/optimizely-sdk/dist/optimizely.json_schema_validator.min');

// Require JSON schema validation for the datafile
var optimizelyClientInstance = optimizely.createInstance({
Expand Down
17 changes: 17 additions & 0 deletions packages/optimizely-sdk/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,27 @@ const umdconfig = {
],
};

// A separate bundle for json schema validator.
const jsonSchemaValidatorConfig = {
plugins: [
resolve(),
commonjs(),
],
external: ['json-schema', '@optimizely/js-sdk-utils'],
input: 'lib/utils/json_schema_validator/index.js',
output: {
exports: 'named',
format: 'cjs',
file: 'dist/optimizely.json_schema_validator.min.js',
plugins: [ terser() ],
}
};

export default [
BUILD_ALL && getCjsConfigForPlatform('node'),
BUILD_ALL && getCjsConfigForPlatform('browser'),
BUILD_ALL && getCjsConfigForPlatform('react_native'),
BUILD_ALL && esModuleConfig,
BUILD_ALL && jsonSchemaValidatorConfig,
(BUILD_ALL || BUILD_UMD_BUNDLE) && umdconfig,
].filter(config => config);