Skip to content

Commit

Permalink
use webpack config to generate browser code directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Brandt committed Nov 14, 2018
1 parent 31c828d commit 13be72d
Show file tree
Hide file tree
Showing 6 changed files with 3,024 additions and 2,233 deletions.
34 changes: 19 additions & 15 deletions packages/optimizely-sdk/karma.bs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ module.exports = function(config) {
//plugins
plugins: ['karma-mocha', 'karma-webpack', require('karma-browserstack-launcher')],

webpack: {
mode: 'production',
},

//browserStack setup
browserStack: {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_ACCESS_KEY
},

// to avoid DISCONNECTED messages when connecting to BrowserStack
browserDisconnectTimeout : 10000, // default 2000
browserDisconnectTolerance : 1, // default 0
browserNoActivityTimeout : 4*60*1000, //default 10000
captureTimeout : 4*60*1000, //default 60000
browserDisconnectTimeout: 10000, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
captureTimeout: 4 * 60 * 1000, //default 60000

// define browsers
customLaunchers: {
Expand All @@ -37,7 +41,7 @@ module.exports = function(config) {
os_version: '10',
browser: 'edge',
device: null,
browser_version: "15.0"
browser_version: '15.0'
},
bs_firefox_mac: {
base: 'BrowserStack',
Expand All @@ -48,11 +52,11 @@ module.exports = function(config) {
},
bs_ie: {
base: 'BrowserStack',
os: "Windows",
os_version: "7",
browser: "ie",
os: 'Windows',
os_version: '7',
browser: 'ie',
device: null,
browser_version: "10.0"
browser_version: '10.0'
},
bs_iphone6: {
base: 'BrowserStack',
Expand All @@ -69,11 +73,11 @@ module.exports = function(config) {
},
bs_safari: {
base: 'BrowserStack',
os: "OS X",
os_version: "Mountain Lion",
browser: "safari",
os: 'OS X',
os_version: 'Mountain Lion',
browser: 'safari',
device: null,
browser_version: "6.2"
browser_version: '6.2'
}
},

Expand Down Expand Up @@ -131,5 +135,5 @@ module.exports = function(config) {
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
});
};
18 changes: 18 additions & 0 deletions packages/optimizely-sdk/lib/index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@ module.exports = {
}
}
};

if (typeof window !== 'undefined') {
window.optimizelySdk = module.exports;
var _optimizelyClientWarningGiven = false;

Object.defineProperty(window, 'optimizelyClient', {
get: function () {
if (!_optimizelyClientWarningGiven) {
console.warn('Accessing the SDK via window.optimizelyClient is deprecated; please use window.optimizelySdk instead. This alias will be dropped in 3.0.0.');
_optimizelyClientWarningGiven = true;
}

return {
createInstance: window.optimizelySdk.createInstance
};
}
});
}
Loading

0 comments on commit 13be72d

Please sign in to comment.