Skip to content

Commit

Permalink
refactor: Removed Promise Polyfill to reduce bundle size (#417)
Browse files Browse the repository at this point in the history
Summary:

Removed Promise Polyfill from browser entry point to reduce bundle size. A user can still use the SDK in older browsers by including the promise polyfill themselves.

Test plan:
All tests pass by providing promise polyfill as part of the test setup.
  • Loading branch information
zashraf1985 authored Mar 9, 2020
1 parent 5cf5ddc commit 1e00509
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/optimizely-sdk/karma.bs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,

// list of files / patterns to load in the browser
files: ['./lib/index.browser.tests.js'],
files: [
'./node_modules/promise-polyfill/dist/polyfill.min.js',
'./lib/index.browser.tests.js'
],
});
};
6 changes: 5 additions & 1 deletion packages/optimizely-sdk/karma.umd.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,

// list of files / patterns to load in the browser
files: ['./dist/optimizely.browser.umd.min.js', './lib/index.browser.umdtests.js'],
files: [
'./node_modules/promise-polyfill/dist/polyfill.min.js',
'./dist/optimizely.browser.umd.min.js',
'./lib/index.browser.umdtests.js'
],
});
};
1 change: 0 additions & 1 deletion packages/optimizely-sdk/lib/index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('promise-polyfill/dist/polyfill');
var logging = require('@optimizely/js-sdk-logging');
var fns = require('./utils/fns');
var configValidator = require('./utils/config_validator');
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@optimizely/js-sdk-utils": "^0.2.0",
"json-schema": "^0.2.3",
"murmurhash": "0.0.2",
"promise-polyfill": "8.1.0",
"uuid": "^3.3.2"
},
"devDependencies": {
Expand All @@ -62,6 +61,7 @@
"sinon": "^2.3.1",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2",
"promise-polyfill": "8.1.0",
"lodash": "^4.17.11"
},
"publishConfig": {
Expand Down

0 comments on commit 1e00509

Please sign in to comment.