Skip to content

Commit d440082

Browse files
Properly alias/deprecate the change
1 parent 5e7c423 commit d440082

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

packages/optimizely-sdk/CHANGELOG.MD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## Unreleased
8+
9+
### Deprecated
10+
* The UMD build of the SDK now assigns the SDK namespace object to `window.optimizelySdk` rather than to `window.optimizelyClient`. The old name still works, but on its first access a deprecation warning is logged to the console. The alias will be removed in the 3.0.0 release.
11+
112
## 2.1.1
213
June 19, 2018
314

packages/optimizely-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"test": "mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js --recursive",
99
"test-xbrowser": "karma start karma.bs.conf.js --single-run",
10-
"build-browser-umd": "webpack -p lib/index.browser.js dist/optimizely.browser.umd.min.js --output-library-target=umd --output-library=optimizelySdk",
10+
"build-browser-umd": "./scripts/build_browser_umd.sh",
1111
"lint": "eslint lib/**",
1212
"cover": "istanbul cover _mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js",
1313
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash -e
2+
3+
BUNDLE_NAME="optimizelySdk"
4+
5+
npx webpack -p lib/index.browser.js dist/optimizely.browser.umd.min.js \
6+
--output-library-target=umd \
7+
--output-library="$BUNDLE_NAME"
8+
9+
# Append some backwards-compatibility code to the bundle
10+
cat - >> dist/optimizely.browser.umd.min.js <<EOF
11+
12+
13+
window._optimizelyClientWarningGiven = false;
14+
15+
Object.defineProperty(window, 'optimizelyClient', {
16+
get: function () {
17+
if (!window._optimizelyClientWarningGiven) {
18+
console.warn('Accessing the SDK via window.optimizelyClient is deprecated; please use window.optimizelySdk instead. This functionality will be dropped in 3.0.0.');
19+
window._optimizelyClientWarningGiven = true;
20+
}
21+
22+
return {
23+
createInstance: window.optimizelySdk.createInstance
24+
};
25+
}
26+
});
27+
EOF
28+

0 commit comments

Comments
 (0)