You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(build): Resume UMD bundle build, and restore docs (#152)
## Summary
- Restore the `build-browser-umd` npm script, which produces dist/optimizely.browser.umd.min.js
- Change the UMD lib name `optimizelyClient` -> `optimizelySdk`, since the `createInstance` client factory function may be one of several exports of the SDK, in the future.
- (not a visible change) Change Markdown indentation of some bull points, to please my Markdown editor [Typora](https://typora.io/)
This undoes one bit of #135. I hadn't realized that this asset _was_ documented, and does have some uses, like faster/easier prototyping in a browser.
## Test plan
I made a foo.html with
```html
<html>
<head>
<script src="./dist/optimizely.browser.umd.min.js"></script>
<script>
console.log('trying sdk');
window.optimizelySdk
console.log('trying client');
window.optimizelyClient
console.log('trying client');
window.optimizelyClient
</script>
</head>
</html>
```
and it still works:

Copy file name to clipboardExpand all lines: packages/optimizely-sdk/CHANGELOG.MD
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff 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.
Copy file name to clipboardExpand all lines: packages/optimizely-sdk/README.md
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,13 @@ This directory contains the source code for the JavaScript SDK, which is usable
15
15
### Prerequisites
16
16
17
17
Ensure the SDK supports all of the platforms you're targeting. In particular, the SDK targets any ES5-compliant JavaScript environment. We officially support:
18
-
- Node.js >= 4.0.0. By extension, environments like AWS Lambda, Google Cloud Functions, and Auth0 Webtasks are supported as well. Older Node.js releases likely work too (try `npm test` to validate for yourself), but are not formally supported.
19
-
-[Web browsers](https://caniuse.com/#feat=es5)
18
+
- Node.js >= 4.0.0. By extension, environments like AWS Lambda, Google Cloud Functions, and Auth0 Webtasks are supported as well. Older Node.js releases likely work too (try `npm test` to validate for yourself), but are not formally supported.
19
+
-[Web browsers](https://caniuse.com/#feat=es5)
20
20
21
21
Other environments likely are compatible, too, but note that we don't officially support them:
22
-
- Progressive Web Apps, WebViews, and hybrid mobile apps like those built with React Native and Apache Cordova.
23
-
-[Cloudflare Workers](https://developers.cloudflare.com/workers/) and [Fly](https://fly.io/), both of which are powered by recent releases of V8.
24
-
- Anywhere else you can think of that might embed a JavaScript engine. The sky is the limit; experiment everywhere! 🚀
22
+
- Progressive Web Apps, WebViews, and hybrid mobile apps like those built with React Native and Apache Cordova.
23
+
-[Cloudflare Workers](https://developers.cloudflare.com/workers/) and [Fly](https://fly.io/), both of which are powered by recent releases of V8.
24
+
- Anywhere else you can think of that might embed a JavaScript engine. The sky is the limit; experiment everywhere! 🚀
25
25
26
26
Once you've validated that the SDK supports the platforms you're targeting, fetch the package from [NPM](https://www.npmjs.com/package/@optimizely/optimizely-sdk). Using `npm`:
See the Optimizely X Full Stack [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK.
34
34
35
+
The package's entry point is a CommonJS module, which can be used directly in environments which support it (e.g., Node.js, or loaded in a browser via Browserify or RequireJS). Additionally, you can include a standalone bundle of the SDK in your web page by fetching it from [unpkg](https://unpkg.com/):
When evaluated, that bundle assigns the SDK's exports to `window.optimizelySdk`. If you wish to use the asset locally (for example, if unpkg is down), you can find it in your local copy of the package at dist/optimizely.browser.umd.min.js, or [here in GitHub](./dist/optimizely.browser.umd.min.js).
42
+
35
43
Regarding `EventDispatcher`s: In Node.js and browser environments, the default `EventDispatcher` is powered by the [`http/s`](https://nodejs.org/api/http.html) modules and by [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Browser_compatibility), respectively. In all other environments, you must supply your own `EventDispatcher`.
console.warn('Accessing the SDK via window.optimizelyClient is deprecated; please use window.optimizelySdk instead. This alias will be dropped in 3.0.0.');
0 commit comments