Skip to content

Commit 13be72d

Browse files
author
Tyler Brandt
committed
use webpack config to generate browser code directly
1 parent 31c828d commit 13be72d

File tree

6 files changed

+3024
-2233
lines changed

6 files changed

+3024
-2233
lines changed

packages/optimizely-sdk/karma.bs.conf.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ module.exports = function(config) {
1010
//plugins
1111
plugins: ['karma-mocha', 'karma-webpack', require('karma-browserstack-launcher')],
1212

13+
webpack: {
14+
mode: 'production',
15+
},
16+
1317
//browserStack setup
1418
browserStack: {
1519
username: process.env.BROWSER_STACK_USERNAME,
1620
accessKey: process.env.BROWSER_STACK_ACCESS_KEY
1721
},
1822

1923
// to avoid DISCONNECTED messages when connecting to BrowserStack
20-
browserDisconnectTimeout : 10000, // default 2000
21-
browserDisconnectTolerance : 1, // default 0
22-
browserNoActivityTimeout : 4*60*1000, //default 10000
23-
captureTimeout : 4*60*1000, //default 60000
24+
browserDisconnectTimeout: 10000, // default 2000
25+
browserDisconnectTolerance: 1, // default 0
26+
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
27+
captureTimeout: 4 * 60 * 1000, //default 60000
2428

2529
// define browsers
2630
customLaunchers: {
@@ -37,7 +41,7 @@ module.exports = function(config) {
3741
os_version: '10',
3842
browser: 'edge',
3943
device: null,
40-
browser_version: "15.0"
44+
browser_version: '15.0'
4145
},
4246
bs_firefox_mac: {
4347
base: 'BrowserStack',
@@ -48,11 +52,11 @@ module.exports = function(config) {
4852
},
4953
bs_ie: {
5054
base: 'BrowserStack',
51-
os: "Windows",
52-
os_version: "7",
53-
browser: "ie",
55+
os: 'Windows',
56+
os_version: '7',
57+
browser: 'ie',
5458
device: null,
55-
browser_version: "10.0"
59+
browser_version: '10.0'
5660
},
5761
bs_iphone6: {
5862
base: 'BrowserStack',
@@ -69,11 +73,11 @@ module.exports = function(config) {
6973
},
7074
bs_safari: {
7175
base: 'BrowserStack',
72-
os: "OS X",
73-
os_version: "Mountain Lion",
74-
browser: "safari",
76+
os: 'OS X',
77+
os_version: 'Mountain Lion',
78+
browser: 'safari',
7579
device: null,
76-
browser_version: "6.2"
80+
browser_version: '6.2'
7781
}
7882
},
7983

@@ -131,5 +135,5 @@ module.exports = function(config) {
131135
// Concurrency level
132136
// how many browser should be started simultaneous
133137
concurrency: Infinity
134-
})
135-
}
138+
});
139+
};

packages/optimizely-sdk/lib/index.browser.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,21 @@ module.exports = {
7878
}
7979
}
8080
};
81+
82+
if (typeof window !== 'undefined') {
83+
window.optimizelySdk = module.exports;
84+
var _optimizelyClientWarningGiven = false;
85+
86+
Object.defineProperty(window, 'optimizelyClient', {
87+
get: function () {
88+
if (!_optimizelyClientWarningGiven) {
89+
console.warn('Accessing the SDK via window.optimizelyClient is deprecated; please use window.optimizelySdk instead. This alias will be dropped in 3.0.0.');
90+
_optimizelyClientWarningGiven = true;
91+
}
92+
93+
return {
94+
createInstance: window.optimizelySdk.createInstance
95+
};
96+
}
97+
});
98+
}

0 commit comments

Comments
 (0)